Skip to content

Bump release #771

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

Closed
wants to merge 1,052 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1052 commits
Select commit Hold shift + click to select a range
5a822a9
8/3 finished
pdumin Jan 27, 2024
e34e68d
8/4 finished
pdumin Jan 27, 2024
db79001
fix typo
pdumin Jan 27, 2024
582cada
toc update
pdumin Jan 27, 2024
91b35f3
typos fixed
pdumin Jan 27, 2024
6d161ca
removed english text
pdumin Jan 27, 2024
b1a8e02
8/5 finished
pdumin Jan 27, 2024
8c015d3
8/6-7 finished
pdumin Jan 27, 2024
eb16954
fix and update toc
pdumin Jan 28, 2024
a7a0dac
chapter8/1 fixed
pdumin Jan 30, 2024
dd7bb8a
chapter8/2 fixed
pdumin Jan 30, 2024
d24a0c1
chapter8/3 fixed
pdumin Jan 30, 2024
b4bd049
chapter8/4 fixed
pdumin Jan 30, 2024
47c809a
chapter8/5 fixed
pdumin Jan 30, 2024
5893e53
fix title 8/5
pdumin Jan 30, 2024
3f5df27
fix title 8/5 in toc
pdumin Jan 30, 2024
d46939c
Update _toctree.yml title 8
pdumin Jan 30, 2024
e4eae4c
Bump black (#671)
lewtun Jan 31, 2024
e825efb
Merge branch 'huggingface:main' into main
pdumin Jan 31, 2024
b973ea8
fix unexpected token in quiz
pdumin Jan 31, 2024
58ca113
8/2 fixed
pdumin Jan 31, 2024
b62a3a4
8/3 fixed
pdumin Jan 31, 2024
0a33e61
8/4_tf fixed
pdumin Jan 31, 2024
0c72c69
Merge pull request #667 from pdumin/main
MKhalusova Jan 31, 2024
b509066
Update 3b.mdx
chamomile93 Jan 31, 2024
1185e7e
Added translation of chapter 9 and Course Events.
artyomboyko Jan 31, 2024
e3edacb
Added translation of chapter 9 and Course Events.
artyomboyko Jan 31, 2024
e819ed2
Update 5.mdx
chamomile93 Feb 1, 2024
5b4e2bd
Update 7.mdx
chamomile93 Feb 1, 2024
23c121b
Update 10.mdx
chamomile93 Feb 1, 2024
953d8ed
Update chapters/ru/chapter9/6.mdx
artyomboyko Feb 1, 2024
2e98f09
Update chapters/ru/chapter9/7.mdx
artyomboyko Feb 1, 2024
7c70c6b
Update chapters/ru/chapter9/7.mdx
artyomboyko Feb 1, 2024
aebdc91
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
9742e7b
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
05114e9
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
93c9387
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
7fe2432
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
6a8abe0
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
f1719b3
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
e87666a
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
2bba211
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
2991db0
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
d5551b8
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
9c0fce1
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
b9eab04
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
b289071
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
cc95da3
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
d48ca79
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
033ef13
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
4bf3abb
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
c86fb1e
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
e5a6afb
Update chapters/ru/events/1.mdx
artyomboyko Feb 1, 2024
10fb52f
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
198b1c3
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
7ed5ad4
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
6a18d5d
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
8a3edbf
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
f998d19
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
6b24983
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
8e44e89
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
dcac23a
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
b5a52b6
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
41ef527
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
33ddd73
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
2157d04
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
c572649
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
6695d36
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
162a912
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
3eb7d92
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
a044b40
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
9c9fa42
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
ea5b060
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
8a94691
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
95127a1
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
e048955
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
4658529
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
0ea1589
Update chapters/ru/events/2.mdx
artyomboyko Feb 1, 2024
f44d5cb
Merge pull request #673 from blademoon/main
MKhalusova Feb 1, 2024
f9a0ca5
Capture the current state of the translation. Two files are translate…
artyomboyko Feb 2, 2024
5ff4f2c
Made a full translation of Chapter 2.
artyomboyko Feb 4, 2024
fb8c1f8
Fix problem in .
artyomboyko Feb 4, 2024
fe42b4f
Deleting JupyterLab backup files.
artyomboyko Feb 4, 2024
afc8211
Update 8.mdx
artyomboyko Feb 4, 2024
bd349ce
Update 8.mdx
artyomboyko Feb 4, 2024
f8af3dd
remove original sentence
fabridamicelli Feb 13, 2024
84d5caf
Update chapters/ru/chapter2/2.mdx
artyomboyko Feb 13, 2024
ca51532
Update chapters/ru/chapter2/2.mdx
artyomboyko Feb 13, 2024
772cf68
Update chapters/ru/chapter2/4.mdx
artyomboyko Feb 13, 2024
2626239
Update chapters/ru/chapter2/5.mdx
artyomboyko Feb 13, 2024
5b7d0a5
Update chapters/ru/chapter2/5.mdx
artyomboyko Feb 13, 2024
cd84491
Update chapters/ru/chapter2/5.mdx
artyomboyko Feb 13, 2024
316f484
Update chapters/ru/chapter2/5.mdx
artyomboyko Feb 13, 2024
e5c1cfe
Update chapters/ru/chapter2/2.mdx
artyomboyko Feb 13, 2024
aef95c1
Update 2.mdx
artyomboyko Feb 13, 2024
f00ba32
Update 2.mdx
artyomboyko Feb 13, 2024
2a19ee2
Update chapters/ru/chapter2/2.mdx
artyomboyko Feb 13, 2024
8c6a58c
Update 2.mdx
artyomboyko Feb 13, 2024
c177017
Update chapters/ru/chapter2/2.mdx
artyomboyko Feb 13, 2024
7889838
Update chapters/ru/chapter2/3.mdx
artyomboyko Feb 13, 2024
98b0f47
Update chapters/ru/chapter2/4.mdx
artyomboyko Feb 13, 2024
3c686e5
Update 4.mdx
artyomboyko Feb 13, 2024
6dfa7e1
Merge pull request #678 from blademoon/main
MKhalusova Feb 13, 2024
dcab735
Merge pull request #640 from fabridamicelli/de_ch_4_part2
MKhalusova Feb 13, 2024
eaca7dd
Minor edits to the table of contents, and the titles of the final tes…
artyomboyko Feb 19, 2024
e63a663
Merge pull request #685 from blademoon/main
MKhalusova Feb 21, 2024
4acf20c
chapter 2's introduction hackable French translation
FlorentFlament Mar 4, 2024
460d07a
Chapter 2.2 - doesn't make sense French translation
FlorentFlament Mar 4, 2024
c3c4ea0
[doc-fix] Add accelerate required for notebook 3/3
dimaioksha Mar 10, 2024
2aed933
translation fix
brealid Mar 15, 2024
b1e8a6d
fix: typo
qcgzxw Mar 20, 2024
eeacec0
fix formatting
qcgzxw Mar 20, 2024
eef7403
remove unnecessary translate
qcgzxw Mar 20, 2024
cb3fce6
fix typo and formatting in Chinese translation
qcgzxw Mar 20, 2024
f983af5
fix zh-cn translation for chapter 3-6
ruochenhua Mar 21, 2024
bd546fd
fix formatting issue for zh-cn on chapter 5-8
ruochenhua Mar 26, 2024
755ece4
Merge branch 'main' of https://github.com/ruochenhua/huggingface_course
ruochenhua Mar 26, 2024
d01e9c0
fix zh-cn translation on chapter 4-6
ruochenhua Mar 26, 2024
08ae78b
docs: mdx typo
Nagi-ovo Mar 28, 2024
52c1ff0
fix deactivate
qgallouedec Mar 31, 2024
2715b60
tip to install datasets
0xm4ze Apr 24, 2024
194a6a0
修正翻译
buqieryul Apr 24, 2024
742d174
fix zh
buqieryul Apr 25, 2024
b79da5d
fix zh
buqieryul Apr 25, 2024
9f55f69
Changing tokenized_dataset to tokenized_datasets
jpodivin May 5, 2024
b1d79d1
Update 9.mdx
partrita May 8, 2024
43ce993
Update 2.mdx
partrita May 9, 2024
b340fbf
[zh-CN/TW] bugfix of broken image link: Companies using Hugging Face
jks-liu May 15, 2024
4b729b9
[zh-CN/TW] pipeline name translation is not needed
jks-liu May 15, 2024
446da36
[zh-CN/TW] translation of `Hub`: 集线器(集線器) => 模型中心
jks-liu May 15, 2024
231491f
correct zh translation
May 16, 2024
f52d6d8
correct zh-TW translation
May 16, 2024
7065a5f
Fix typo in korean translation
osanseviero May 17, 2024
93e49a8
Changing tokenized_dataset to tokenized_datasets
osanseviero May 17, 2024
60ad585
Fix deactivate command
osanseviero May 17, 2024
bb1c442
Fix typo
osanseviero May 17, 2024
a91486c
Add accelerate required for notebook
osanseviero May 17, 2024
d7e3812
Merge pull request #706 from memorylorry/correct_zh_doc
xianbaoqian May 21, 2024
a51913e
Merge pull request #705 from jks-liu/pr-zh
xianbaoqian May 21, 2024
c8572a9
Merge branch 'main' into main
xianbaoqian May 21, 2024
2cc0ab7
Merge pull request #701 from buqieryul/main
xianbaoqian May 21, 2024
47e5ad7
Merge branch 'main' into main
xianbaoqian May 21, 2024
0c2e096
Merge pull request #696 from ruochenhua/main
xianbaoqian May 21, 2024
3aaa344
Merge branch 'main' into chapter0
xianbaoqian May 21, 2024
bf4f283
Merge pull request #695 from qcgzxw/chapter0
xianbaoqian May 21, 2024
7d9fd84
Merge pull request #693 from qcgzxw/main
xianbaoqian May 21, 2024
80eb463
Merge branch 'main' into main
xianbaoqian May 21, 2024
3f2ad53
Merge pull request #691 from brealid/main
xianbaoqian May 21, 2024
cfb66ae
Merge pull request #700 from tal7aouy/tal7aouy
lunarflu Aug 21, 2024
d6f1620
Merge pull request #688 from FlorentFlament/doesnt-make-sense
lunarflu Aug 21, 2024
647d1ad
Merge pull request #687 from FlorentFlament/main
lunarflu Aug 21, 2024
472f531
Merge pull request #676 from yanisallouch/patch-7
lunarflu Aug 22, 2024
c368427
Merge pull request #675 from yanisallouch/patch-6
lunarflu Aug 22, 2024
b966bcc
Merge pull request #674 from yanisallouch/patch-5
lunarflu Aug 22, 2024
2f54cd0
Merge pull request #672 from yanisallouch/patch-4
lunarflu Aug 22, 2024
9585b2a
Merge pull request #589 from gyheo/main
lunarflu Aug 23, 2024
ea35ade
Merge pull request #533 from askfor/patch-2
lunarflu Aug 23, 2024
a38ba80
Merge pull request #514 from nvoorhies/main
lunarflu Sep 5, 2024
bfd0947
finish review chapter7 8 9
yaoqih Sep 10, 2024
cadd0ab
format fr/chapter9/4.mdx
yaoqih Sep 10, 2024
d388a7e
Merge branch 'main' into main
yaoqih Sep 10, 2024
7806601
Update 7.mdx
yaoqih Sep 10, 2024
1652378
Merge branch 'main' of https://github.com/yaoqih/course
yaoqih Sep 10, 2024
685e7f2
create rum folder
eduard-balamatiuc Sep 22, 2024
1bda24c
Add Steven as reviewer (#746)
lewtun Sep 23, 2024
0313528
update toctree
eduard-balamatiuc Sep 24, 2024
6c1cc5f
translate chapter0-1
eduard-balamatiuc Sep 24, 2024
f4f11b9
update course0-1
eduard-balamatiuc Sep 26, 2024
5a6d86a
remove files and folders that are not updated
eduard-balamatiuc Sep 26, 2024
b330c3a
add the rum folder in the build documentation
eduard-balamatiuc Sep 26, 2024
0dbfc37
Merge pull request #1 from SigmoidAI/translation-chapter-0
eduard-balamatiuc Sep 26, 2024
e5248d2
Introduction to Argilla
nataliaElv Oct 22, 2024
c5cfaaa
Set up Argilla
nataliaElv Oct 22, 2024
dc6251f
Merge pull request #753 from SigmoidAI/main
stevhliu Oct 29, 2024
ef81c0b
Remove mention of chapters 10-12
erinys Nov 5, 2024
6998b7d
Merge pull request #754 from huggingface/ann-intro-cleanup
erinys Nov 6, 2024
14e8f4e
finish review ZH-CN chapter1-6
yaoqih Nov 19, 2024
9623b46
code_format for chaper 1-6
yaoqih Nov 19, 2024
ffbbcc8
Fixed wrong full width colon
yaoqih Nov 19, 2024
b91e806
Initial draft
nataliaElv Nov 20, 2024
5ce7a3d
Merge pull request #743 from yaoqih/main
xianbaoqian Nov 20, 2024
d32647b
Merge branch 'huggingface:main' into argilla-chapter
nataliaElv Nov 20, 2024
d279b9f
Fix
nataliaElv Nov 20, 2024
4d47d89
Corrections section 2
nataliaElv Nov 20, 2024
5b03fdd
Section 3 improvements
nataliaElv Nov 20, 2024
3f54096
More improvements
nataliaElv Nov 20, 2024
b2bf23b
Images & apply review comments
nataliaElv Nov 21, 2024
12d67bb
Apply suggestions from code review
nataliaElv Nov 21, 2024
20f7313
Fix style
nataliaElv Nov 22, 2024
944b877
Updated images and banners
nataliaElv Nov 22, 2024
9bb7a59
More screenshots
nataliaElv Nov 22, 2024
ea07f11
Fix quiz inline code
nataliaElv Nov 22, 2024
cf1d194
More improvements from reviews
nataliaElv Nov 25, 2024
c2a74e4
Added chapter 0 and initiated _toctree for Nepali Language
CRLannister Dec 1, 2024
d87ee46
Added Nepali language code in the workflow github actions
CRLannister Dec 1, 2024
d06b4cc
Ran make styles without any errors!
CRLannister Dec 1, 2024
384735e
Update chapters/ne/chapter0/1.mdx
CRLannister Dec 2, 2024
55353ab
Update chapters/ne/chapter0/1.mdx
CRLannister Dec 2, 2024
474d65e
Made same codeblocks for activate and deactivate
CRLannister Dec 2, 2024
476dc72
Merge pull request #761 from CRLannister/main
stevhliu Dec 4, 2024
244e86f
Started Chapter 1 for Nepali Language
CRLannister Dec 13, 2024
69ad00a
Added 1.mdx file for Nepali Language
CRLannister Dec 13, 2024
839ef31
removed the translation for Author Names
CRLannister Dec 13, 2024
4a49e48
New chapter: Argilla (#756)
pcuenca Jan 8, 2025
05a8f89
Remove new from Gradio chapter (#769)
lewtun Jan 16, 2025
17d11ca
Add instructions for deployment (#770)
lewtun Jan 16, 2025
04209ea
Merge branch 'release' into bump_release
lewtun Jan 16, 2025
832bdba
Update 4.mdx
renweizhukov Jan 20, 2025
013f293
Merge pull request #765 from CRLannister/main
stevhliu Jan 28, 2025
7bc134b
initial copy from smol-course
burtenshaw Jan 29, 2025
666ffe3
Replace Gradio deprecated methods in 3.mdx
renweizhukov Jan 29, 2025
995493b
convert smol course material into nlp course style
burtenshaw Jan 30, 2025
beec8b5
review text and read through
burtenshaw Jan 30, 2025
abb20be
fix: typo in French course (chapter3/1.mdx)
lauthieb Feb 2, 2025
cf59807
fix: typo in French course (chapter8/7.mdx)
lauthieb Feb 2, 2025
32eed37
Merge pull request #780 from lauthieb/patch-2
Vaibhavs10 Feb 3, 2025
ffbae1c
Merge pull request #779 from lauthieb/patch-1
Vaibhavs10 Feb 3, 2025
ab57fd6
Merge pull request #778 from renweizhukov/patch-2
Vaibhavs10 Feb 3, 2025
fb04c75
Merge pull request #772 from renweizhukov/patch-1
Vaibhavs10 Feb 3, 2025
4cb5f93
add links to colab
burtenshaw Feb 5, 2025
f7fc25d
add quiz app
burtenshaw Feb 5, 2025
564d9ec
add toc
burtenshaw Feb 5, 2025
edcf049
format code blocks
burtenshaw Feb 5, 2025
267c171
combine pages together and add extra guidance
burtenshaw Feb 5, 2025
a9847d0
update toc and format snippets
burtenshaw Feb 5, 2025
82b1d4a
update structure
burtenshaw Feb 5, 2025
549612b
followinf readthrough: simplify and add more tips
burtenshaw Feb 6, 2025
881865e
format code blocks
burtenshaw Feb 6, 2025
a386bbf
suggestions in intro page
burtenshaw Feb 11, 2025
6cefbc9
respond to suggestions on chat templates page
burtenshaw Feb 11, 2025
3b7cc5a
Update chapters/en/chapter11/3.mdx
burtenshaw Feb 11, 2025
c6800f1
Update chapters/en/chapter11/5.mdx
burtenshaw Feb 11, 2025
844d715
Update chapters/en/chapter11/5.mdx
burtenshaw Feb 11, 2025
7d0519c
Merge branch 'add-supervised-finetuning' of https://github.com/burten…
burtenshaw Feb 11, 2025
3f9815c
respond to suggestions in SFT page
burtenshaw Feb 11, 2025
c47a5a5
improve loss illustrations on sft page
burtenshaw Feb 11, 2025
d66fa86
respond to feedback in chat template
burtenshaw Feb 12, 2025
21c8dd1
respond to feedback on sft section
burtenshaw Feb 12, 2025
5d4025d
respond to feedback on lora section
burtenshaw Feb 12, 2025
e0ecc8c
respond to feedback in unit 5
burtenshaw Feb 12, 2025
2c30171
update toc with new tag and subtitle
burtenshaw Feb 14, 2025
cc7ddee
improve intro congruency with previous chapters
burtenshaw Feb 14, 2025
f040b6c
make chat templates more about structure
burtenshaw Feb 14, 2025
6d2a54c
add packing and references to the sft section
burtenshaw Feb 14, 2025
3a2ee3c
fix qlora mistake in lora page
burtenshaw Feb 14, 2025
a02b2d2
add more benchmarks to evaluation section
burtenshaw Feb 14, 2025
c74ebd3
add final quizzes to quiz section
burtenshaw Feb 17, 2025
f1a8e79
Merge pull request #777 from burtenshaw/add-supervised-finetuning
burtenshaw Feb 17, 2025
af2b0f3
Merge remote-tracking branch 'origin/release' into bump_release
burtenshaw Feb 17, 2025
612eed7
Merge branch 'bump_release' of https://github.com/huggingface/course …
burtenshaw Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ If you get stuck, check out one of the existing chapters -- this will often show

Once you are happy with the content, open a pull request and tag [@lewtun](https://github.com/lewtun) for a review. We recommend adding the first chapter draft as a single pull request -- the team will then provide feedback internally to iterate on the content 🤗!

## Deploying to hf.co/course (for HF staff)

The course content is deployed to [hf.co/course](https://huggingface.co/learn/nlp-course/chapter1/1) by triggering the [GitHub CI](.github/workflows/build_documentation.yml) from the `release` branch. To trigger the build, first create a new branch from `main` that will be used to update the current state on `release`:

```shell
git checkout main
git checkout -b bump_release
```

Next, resolve any conflicts between the `release` and `bump_release` branches. Since this is tiresome to do manually, we can do the following to accept the latest changes:

```shell
git checkout bump_release
git merge -s ours release
```

Next, push the `bump_release` branch and open a PR against `release` (not `main`!). Here is an example [PR](https://github.com/huggingface/course/pull/768). Once the CI is green, merge the PR and this will trigger the GitHub CI to build the new course content. This takes around 10-15 minutes, after which the latest changes will be visible on [hf.co/course](https://huggingface.co/learn/nlp-course/chapter1/1)!


## 🙌 Acknowledgements

The structure of this repo and README are inspired by the wonderful [Advanced NLP with spaCy](https://github.com/ines/spacy-course) course.
22 changes: 20 additions & 2 deletions chapters/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
quiz: 8

- title: 9. Building and sharing demos
new: true
subtitle: I trained a model, but how can I show it off?
sections:
- local: chapter9/1
Expand All @@ -192,7 +191,6 @@
quiz: 9

- title: 10. Curate high-quality datasets
new: true
subtitle: How to use Argilla to create amazing datasets
sections:
- local: chapter10/1
Expand All @@ -211,6 +209,26 @@
title: End-of-chapter quiz
quiz: 10

- title: 11. Fine-tune Large Language Models
subtitle: Use Supervised Fine-tuning and Low-Rank Adaptation to fine-tune a large language model
new: true
sections:
- local: chapter11/1
title: Introduction
- local: chapter11/2
title: Chat Templates
- local: chapter11/3
title: Fine-Tuning with SFTTrainer
- local: chapter11/4
title: LoRA (Low-Rank Adaptation)
- local: chapter11/5
title: Evaluation
- local: chapter11/6
title: Conclusion
- local: chapter11/7
title: Exam Time!
quiz: 11

- title: Course Events
sections:
- local: events/1
Expand Down
33 changes: 33 additions & 0 deletions chapters/en/chapter11/1.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Supervised Fine-Tuning

In [Chapter 2 Section 2](/course/chapter2/2), we saw that generative language models can be fine-tuned on specific tasks like summarization and question answering. However, nowadays it is far more common to fine-tune language models on a broad range of tasks simultaneously; a method known as supervised fine-tuning (SFT). This process helps models become more versatile and capable of handling diverse use cases. Most LLMs that people interact with on platforms like ChatGPT have undergone SFT to make them more helpful and aligned with human preferences. We will separate this chapter into four sections:

## 1️⃣ Chat Templates

Chat templates structure interactions between users and AI models, ensuring consistent and contextually appropriate responses. They include components like system prompts and role-based messages.

## 2️⃣ Supervised Fine-Tuning

Supervised Fine-Tuning (SFT) is a critical process for adapting pre-trained language models to specific tasks. It involves training the model on a task-specific dataset with labeled examples. For a detailed guide on SFT, including key steps and best practices, see [The supervised fine-tuning section of the TRL documentation](https://huggingface.co/docs/trl/en/sft_trainer).

## 3️⃣ Low Rank Adaptation (LoRA)

Low Rank Adaptation (LoRA) is a technique for fine-tuning language models by adding low-rank matrices to the model's layers. This allows for efficient fine-tuning while preserving the model's pre-trained knowledge. One of the key benefits of LoRA is the significant memory savings it offers, making it possible to fine-tune large models on hardware with limited resources.

## 4️⃣ Evaluation

Evaluation is a crucial step in the fine-tuning process. It allows us to measure the performance of the model on a task-specific dataset.

<Tip>
⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend <a href="https://huggingface.co/join">creating an account</a>.
</Tip>

## References

- [Transformers documentation on chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating)
- [Script for Supervised Fine-Tuning in TRL](https://github.com/huggingface/trl/blob/main/examples/scripts/sft.py)
- [`SFTTrainer` in TRL](https://huggingface.co/docs/trl/main/en/sft_trainer)
- [Direct Preference Optimization Paper](https://arxiv.org/abs/2305.18290)
- [Supervised Fine-Tuning with TRL](https://huggingface.co/docs/trl/main/en/tutorials/supervised_finetuning)
- [How to fine-tune Google Gemma with ChatML and Hugging Face TRL](https://github.com/huggingface/alignment-handbook)
- [Fine-tuning LLM to Generate Persian Product Catalogs in JSON Format](https://huggingface.co/learn/cookbook/en/fine_tuning_llm_to_generate_persian_product_catalogs_in_json_format)
254 changes: 254 additions & 0 deletions chapters/en/chapter11/2.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
<CourseFloatingBanner chapter={2}
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/course/en/chapter11/section2.ipynb"},
]} />

# Chat Templates

## Introduction

Chat templates are essential for structuring interactions between language models and users. Whether you're building a simple chatbot or a complex AI agent, understanding how to properly format your conversations is crucial for getting the best results from your model. In this guide, we'll explore what chat templates are, why they matter, and how to use them effectively.

<Tip>
Chat templates are crucial for:
- Maintaining consistent conversation structure
- Ensuring proper role identification
- Managing context across multiple turns
- Supporting advanced features like tool use
</Tip>

## Model Types and Templates

### Base Models vs Instruct Models
A base model is trained on raw text data to predict the next token, while an instruct model is fine-tuned specifically to follow instructions and engage in conversations. For example, [`SmolLM2-135M`](https://huggingface.co/HuggingFaceTB/SmolLM2-135M) is a base model, while [`SmolLM2-135M-Instruct`](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) is its instruction-tuned variant.

Instuction tuned models are trained to follow a specific conversational structure, making them more suitable for chatbot applications. Moreover, instruct models can handle complex interactions, including tool use, multimodal inputs, and function calling.

To make a base model behave like an instruct model, we need to format our prompts in a consistent way that the model can understand. This is where chat templates come in. ChatML is one such template format that structures conversations with clear role indicators (system, user, assistant). Here's a guide on [ChatML](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/blob/e2c3f7557efbdec707ae3a336371d169783f1da1/tokenizer_config.json#L146).

<Tip warning={true}>
When using an instruct model, always verify you're using the correct chat template format. Using the wrong template can result in poor model performance or unexpected behavior. The easiest way to ensure this is to check the model tokenizer configuration on the Hub. For example, the `SmolLM2-135M-Instruct` model uses [this configuration](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/blob/e2c3f7557efbdec707ae3a336371d169783f1da1/tokenizer_config.json#L146).
</Tip>

### Common Template Formats

Before diving into specific implementations, it's important to understand how different models expect their conversations to be formatted. Let's explore some common template formats using a simple example conversation:

We'll use the following conversation structure for all examples:

```python
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
{"role": "assistant", "content": "Hi! How can I help you today?"},
{"role": "user", "content": "What's the weather?"},
]
```

This is the ChatML template used in models like SmolLM2 and Qwen 2:

```sh
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
Hello!<|im_end|>
<|im_start|>assistant
Hi! How can I help you today?<|im_end|>
<|im_start|>user
What's the weather?<|im_start|>assistant
```

This is using the `mistral` template format:

```sh
<s>[INST] You are a helpful assistant. [/INST]
Hi! How can I help you today?</s>
[INST] Hello! [/INST]
```

Key differences between these formats include:
1. **System Message Handling**:
- Llama 2 wraps system messages in `<<SYS>>` tags
- Llama 3 uses `<|system|>` tags with `</s>` endings
- Mistral includes system message in the first instruction
- Qwen uses explicit `system` role with `<|im_start|>` tags
- ChatGPT uses `SYSTEM:` prefix

2. **Message Boundaries**:
- Llama 2 uses `[INST]` and `[/INST]` tags
- Llama 3 uses role-specific tags (`<|system|>`, `<|user|>`, `<|assistant|>`) with `</s>` endings
- Mistral uses `[INST]` and `[/INST]` with `<s>` and `</s>`
- Qwen uses role-specific start/end tokens

3. **Special Tokens**:
- Llama 2 uses `<s>` and `</s>` for conversation boundaries
- Llama 3 uses `</s>` to end each message
- Mistral uses `<s>` and `</s>` for turn boundaries
- Qwen uses role-specific start/end tokens

Understanding these differences is key to working with various models. Let's look at how the transformers library helps us handle these variations automatically:

```python
from transformers import AutoTokenizer

# These will use different templates automatically
mistral_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1")
qwen_tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-7B-Chat")
smol_tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM2-135M-Instruct")

messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
]

# Each will format according to its model's template
mistral_chat = mistral_tokenizer.apply_chat_template(messages, tokenize=False)
qwen_chat = qwen_tokenizer.apply_chat_template(messages, tokenize=False)
smol_chat = smol_tokenizer.apply_chat_template(messages, tokenize=False)
```

<details>
<summary>Click to see template examples</summary>

Qwen 2 and SmolLM2 ChatML template:

```sh
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
Hello!<|im_end|>
<|im_start|>assistant
Hi! How can I help you today?<|im_end|>
<|im_start|>user
What's the weather?<|im_start|>assistant
```

Mistral template:

```sh
<s>[INST] You are a helpful assistant. [/INST]
Hi! How can I help you today?</s>
[INST] Hello! [/INST]
```

</details>


### Advanced Features
Chat templates can handle more complex scenarios beyond just conversational interactions, including:

1. **Tool Use**: When models need to interact with external tools or APIs
2. **Multimodal Inputs**: For handling images, audio, or other media types
3. **Function Calling**: For structured function execution
4. **Multi-turn Context**: For maintaining conversation history

<Tip>
When implementing advanced features:
- Test thoroughly with your specific model. Vision and tool use template are particularly diverse.
- Monitor token usage carefully between each feature and model.
- Document the expected format for each feature
</Tip>

For multimodal conversations, chat templates can include image references or base64-encoded images:

```python
messages = [
{
"role": "system",
"content": "You are a helpful vision assistant that can analyze images.",
},
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image", "image_url": "https://example.com/image.jpg"},
],
},
]
```

Here's an example of a chat template with tool use:

```python
messages = [
{
"role": "system",
"content": "You are an AI assistant that can use tools. Available tools: calculator, weather_api",
},
{"role": "user", "content": "What's 123 * 456 and is it raining in Paris?"},
{
"role": "assistant",
"content": "Let me help you with that.",
"tool_calls": [
{
"tool": "calculator",
"parameters": {"operation": "multiply", "x": 123, "y": 456},
},
{"tool": "weather_api", "parameters": {"city": "Paris", "country": "France"}},
],
},
{"role": "tool", "tool_name": "calculator", "content": "56088"},
{
"role": "tool",
"tool_name": "weather_api",
"content": "{'condition': 'rain', 'temperature': 15}",
},
]
```

## Best Practices

### General Guidelines
When working with chat templates, follow these key practices:

1. **Consistent Formatting**: Always use the same template format throughout your application
2. **Clear Role Definition**: Clearly specify roles (system, user, assistant, tool) for each message
3. **Context Management**: Be mindful of token limits when maintaining conversation history
4. **Error Handling**: Include proper error handling for tool calls and multimodal inputs
5. **Validation**: Validate message structure before sending to the model

<Tip warning={true}>
Common pitfalls to avoid:
- Mixing different template formats in the same application
- Exceeding token limits with long conversation histories
- Not properly escaping special characters in messages
- Forgetting to validate input message structure
- Ignoring model-specific template requirements
</Tip>

## Hands-on Exercise

Let's practice implementing chat templates with a real-world example.

<Tip>
Follow these steps to convert the `HuggingFaceTB/smoltalk` dataset into chatml format:

1. Load the dataset:
```python
from datasets import load_dataset

dataset = load_dataset("HuggingFaceTB/smoltalk")
```

2. Create a processing function:
```python
def convert_to_chatml(example):
return {
"messages": [
{"role": "user", "content": example["input"]},
{"role": "assistant", "content": example["output"]},
]
}
```

3. Apply the chat template using your chosen model's tokenizer

Remember to validate your output format matches your target model's requirements!
</Tip>

## Additional Resources

- [Hugging Face Chat Templating Guide](https://huggingface.co/docs/transformers/main/en/chat_templating)
- [Transformers Documentation](https://huggingface.co/docs/transformers)
- [Chat Templates Examples Repository](https://github.com/chujiezheng/chat_templates)
Loading