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

[docs] Task guides #1332

Merged
merged 4 commits into from
Jan 27, 2024
Merged

[docs] Task guides #1332

merged 4 commits into from
Jan 27, 2024

Conversation

stevhliu
Copy link
Member

@stevhliu stevhliu commented Jan 9, 2024

This is a proof-of-concept and not ready to merge or review! I'm starting with the prompt-based methods as an example.

I feel like the task guides kind of take the focus away from how to apply a PEFT method and are more of a guide for how to fine-tune a model for a specific task. Most of the guides' content is about preprocessing and getting a dataset/model ready for a specific task and training it. Only a short section of the guide is dedicated to applying the PEFT method. I think we can point users to the Transformers docs for how-to fine for a specific task and/or link to our notebook collection in our PEFT Hub organization (I'll work on getting this updated and ready!). This way, the focus is less on the specific task and more on the specific PEFT method, and users can generalize this to other tasks. Another benefit is it makes it easier to maintain and keep the docs updated since we don't have to add to the docs for every different task versus PEFT method. This would keep the docs cleaner and more focused I think.

Let me know what you think @BenjaminBossan @pacman100 @younesbelkada!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Super good, thanks! I like the idea of condensing the individual guides into a single one to highlight the commonalities and differences, and to refer to existing docs to avoid duplication.

I ran into a couple of minor errors, please check out my comments.

A prompt can describe a task or provide an example of the task you want the model to learn. Instead of manually creating these prompts, soft prompting methods add learnable parameters to the input embeddings that can be optimized for a specific task while keeping the pretrained model's parameters frozen. This makes it both faster and easier to finetune large language models (LLMs) for new downstream tasks.

The PEFT library supports several types of prompting methods (p-tuning, prefix tuning, prompt tuning, multitask prompt tuning) and you can learn more about how these methods work conceptually in the [Soft prompts](../conceptual_guides/prompting) guide. If you're interested in applying these methods to other tasks, take a look at our collection of [notebooks](https://huggingface.co/spaces/PEFT/soft-prompting)!

Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to start a new subsection here? The two paragraphs before are general intros, what comes next is a concrete guide.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's ok to not add a new subsection here. Between the intro paragraphs and the concrete guide is the <Tip>, which belongs to the intro for setting expectations, and just a short setup to install the necessary libraries. Since it's so short, I don't think we need to break it down so granularly and it could be included in the intro as a transition to the code.

docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
"trainable params: 300,288 || all params: 559,514,880 || trainable%: 0.05366935013417338"
```

</hfoption>
Copy link
Member

Choose a reason for hiding this comment

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

Running the code with prefix-tuning or prompt-tuning resulted in errors for me. I had to add:

classes = [k.replace("_", " ") for k in ds["train"].features["Label"].names]
ds = ds.map(
    lambda x: {"text_label": [classes[label] for label in x["Label"]]},
    batched=True,
    num_proc=1,
)

before calling processed_ds = ds.map(...), which I just copied from the original docs. Probably it could be added to preprocess_function to avoid mapping twice.

docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
@stevhliu
Copy link
Member Author

stevhliu commented Jan 9, 2024

Thanks for your excellent review as usual @BenjaminBossan! 🔥 I'll wait a bit for the other maintainers to chime in if they want, and if we're all on board, then the next steps would be:

  1. Complete the PEFT Hub organization with all the notebooks so we can refer to them from the docs
  2. Condense the LoRA guides
  3. Add guides for methods that aren't included in the docs yet, but they're in the peft/examples folder

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Great. Let's see what the others have to say.

Copy link
Contributor

@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

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

Thank you @stevhliu for consolidating the soft-prompt based methods in a single task guide. I really like the hfoptions based toggle to see the changes required between these methods while trying to solve a given task. 🔥🚀✨

Left a few comments/nits.

docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
docs/source/task_guides/prompt_based_methods.md Outdated Show resolved Hide resolved
@stevhliu stevhliu marked this pull request as ready for review January 18, 2024 19:50
Copy link
Contributor

@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

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

Thank you @stevhliu! 🚀

@pacman100 pacman100 merged commit bfc102c into huggingface:main Jan 27, 2024
14 checks passed
@stevhliu stevhliu deleted the task-guides branch January 29, 2024 16:48
BenjaminBossan pushed a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
* soft prompt guides

* small edits

* feedback

* feedback
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.

4 participants