-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
[docs] LLM prompting guide #26274
[docs] LLM prompting guide #26274
Conversation
The documentation is not available anymore as the PR was closed or merged. |
The first draft of the LLM prompting guide is ready for review, let me know if anything major is missing. cc @patrickvonplaten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! My main feedback is:
- Let's maybe not pass default parameters to make sure the pipeline call function stays simple. E.g. I think we can remove all the
num_return_sequences=1
statements as well as theeos_token_id=...
statements as the model should have that set as the default (see here). - For task that do pure classification (sentiment analysis) or NER where there is arguably one and only one answer and where the model only generates a few tokens, I think it'd be better to not set
do_sample=True
and instead leave the sampling to be greedy - I don't think we want to introduce any randomness there. Maybe a 1-2 liner explaining the difference could also help there
|
||
This is a wrong answer, it should be 12. In this case, this can be due to the prompt being too basic, or due to the choice | ||
of model, after all we've picked the smallest version of Falcon. Reasoning is difficult for models of all sizes, but larger | ||
models are likely to perform better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice I like this!
* "Lead" the output in the right direction by writing the first word (or even begin the first sentence for the model). | ||
* Use advanced techniques like [Few-shot prompting](#few-shot-prompting) and [Chain-of-thought](#chain-of-thought) | ||
* Test your prompts with different models to assess their robustness. | ||
* Version and track the performance of your prompts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tips!
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great :)
Only left a few comments
Co-authored-by: Lysandre Debut <hi@lysand.re>
Feel free to merge when satisfied with it! |
@LysandreJik I'm happy with it, but I think we should wait for @gante to review it once he's back from vacation. |
Gently pinging @gante for a review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great guide, with clear examples, great suggestions, and relevant caveats. Big thumbs up, thank you for writing this guide @MKhalusova 💛
* llm prompting guide * updated code examples * an attempt to fix the code example tests * set seed in examples * added a doctest comment * added einops to the doc_test_job * string formatting * string formatting, again * added the toc to slow_documentation_tests.txt * minor list fix * string formatting + pipe renamed * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * replaced max_length with max_new_tokens and updated the outputs to match * minor formatting fix * removed einops from circleci config * Apply suggestions from code review Co-authored-by: Lysandre Debut <hi@lysand.re> * removed einops and trust_remote_code parameter --------- Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Lysandre Debut <hi@lysand.re>
* llm prompting guide * updated code examples * an attempt to fix the code example tests * set seed in examples * added a doctest comment * added einops to the doc_test_job * string formatting * string formatting, again * added the toc to slow_documentation_tests.txt * minor list fix * string formatting + pipe renamed * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * replaced max_length with max_new_tokens and updated the outputs to match * minor formatting fix * removed einops from circleci config * Apply suggestions from code review Co-authored-by: Lysandre Debut <hi@lysand.re> * removed einops and trust_remote_code parameter --------- Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Lysandre Debut <hi@lysand.re>
* llm prompting guide * updated code examples * an attempt to fix the code example tests * set seed in examples * added a doctest comment * added einops to the doc_test_job * string formatting * string formatting, again * added the toc to slow_documentation_tests.txt * minor list fix * string formatting + pipe renamed * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * replaced max_length with max_new_tokens and updated the outputs to match * minor formatting fix * removed einops from circleci config * Apply suggestions from code review Co-authored-by: Lysandre Debut <hi@lysand.re> * removed einops and trust_remote_code parameter --------- Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Lysandre Debut <hi@lysand.re>
What does this PR do?
This PR addresses part 2.2 ("Prompting" ) of the issue #24575
It adds an LLM Prompting Guide to the docs that covers the following topics:
Let me know, if there's anything missing that has to be included.