> For the complete documentation index, see [llms.txt](https://opencampus.gitbook.io/opencampus-machine-learning-program/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://opencampus.gitbook.io/opencampus-machine-learning-program/courses/machine-learning-with-tensorflow/week-4-convolutional-neural-networks-part-i.md).

# Week 4 - Working with Text Using Hugging Face

### This week you will...

* Build an end-to-end NLP pipeline that classifies AG News articles into World, Sports, Business, or Sci/Tech.
* Use a pretrained DistilBERT tokenizer to convert raw text into model-ready inputs such as token IDs, attention masks, and labels.
* Implement a custom PyTorch `Dataset`, dynamic padding with a data collator, and `DataLoader`s for efficient training and validation.
* Fine-tune DistilBERT using partial layer freezing, tune key hyperparameters, evaluate performance, and save the trained model safely.

### Slides

{% file src="/files/cwHzOrjd9jBhAuHHlxE3" %}

### Additional Learning Resources

* [What is NLP](https://www.youtube.com/watch?v=fLvJ8VdHLA0) (9 min)
* [Embeddings explained](https://www.youtube.com/watch?v=wgfSDrqYMJ4\&t) (8 min)
* Awesome LLM [resource collection](https://github.com/hannibal046/awesome-llm)
* Hugging Face [Transformers Course](https://huggingface.co/learn/llm-course/chapter1/1)

### Until next week you should...

* Prepare questions for your projects for the feedback sessions
* Start on [Module 1: Hyperparameter Optimization](https://learn.deeplearning.ai/specializations/pytorch-for-deep-learning-professional-certificate/lesson/oppq8g/a-conversation-between-laurence-moroney-and-andrew-ng) of Course 2 (PyTorch: Techniques and Ecosystem Tools)
* Start on this [assignment notebook](https://colab.research.google.com/github/opencampus-sh/course-material/blob/main/applied-machine-learning/week-04/Week4_Notebook1_CIFAR-10.ipynb)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://opencampus.gitbook.io/opencampus-machine-learning-program/courses/machine-learning-with-tensorflow/week-4-convolutional-neural-networks-part-i.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
