Skip to content

[docs] LLM prompting guide#26274

Merged
MKhalusova merged 18 commits intohuggingface:mainfrom
MKhalusova:llm_prompting_guide
Oct 12, 2023
Merged

[docs] LLM prompting guide#26274
MKhalusova merged 18 commits intohuggingface:mainfrom
MKhalusova:llm_prompting_guide

Conversation

@MKhalusova
Copy link
Contributor

@MKhalusova MKhalusova commented Sep 19, 2023

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:

  • basics of prompting,
  • encoder-decoder models vs decoder-only models,
  • base vs instruct models,
  • basic prompts to solve common NLP tasks,
  • best practices for prompting,
  • advanced techniques like few-shot learning and chain-of-thought
  • prompting vs fine-tuning

Let me know, if there's anything missing that has to be included.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 20, 2023

The documentation is not available anymore as the PR was closed or merged.

@MKhalusova
Copy link
Contributor Author

The first draft of the LLM prompting guide is ready for review, let me know if anything major is missing. cc @patrickvonplaten

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a 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 the eos_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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tips!

@MKhalusova MKhalusova marked this pull request as ready for review September 22, 2023 13:39
Copy link
Member

@LysandreJik LysandreJik left a 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

@LysandreJik
Copy link
Member

Feel free to merge when satisfied with it!

@MKhalusova
Copy link
Contributor Author

@LysandreJik I'm happy with it, but I think we should wait for @gante to review it once he's back from vacation.

@MKhalusova
Copy link
Contributor Author

Gently pinging @gante for a review :)

Copy link
Contributor

@gante gante left a 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 💛

@MKhalusova MKhalusova merged commit 0ebee8b into huggingface:main Oct 12, 2023
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.

6 participants