Limitation of EmbeddingBag and Manual pooling Classifier

Hi @ developer of this course

Video Title and Ungraded Lab Title: Building a Simple Text Classifier in PyTorch

I was going through the video and lab explanation of simple text classifier explaining embeddingbag and manual pooling techniques to classify distinctive fruit or vegetable classes.

But I just wanted to add that these both techniques would fail when it would come to create a text classifier for synonyms or opposite words as the model works more on words of embedding based on mean, max and sum.

I understood you probably wanted to explain the two concepts here, but mentioning these two techniques limitation would also would have added to content quality of the course.

Like for the product was labelled as fruit for lemon which is correct but the recipe description mentions it as **Lemon and Herd Roasted Chicken" as a fruit recipe in a poor labelling when it comes to realistic contextual understanding of this recipe as lemon is a flavor and the main ingredient is the chicken, so this actually wouldn’t come under neither fruit-recipe not vegetable recipe, rather a distant recipe category of Mixed recipe.:backhand_index_pointing_down:t2:

So model is clearly just working based on encoded labels instead of embeddingbag pooling or manual pooling..

Even Ungraded Lab: Fine Tuning Pre-Trained Text Classifier has the same labelling issue where avacado Toast is labelled as Vegetable here where as Avacado is considered and labelled as fruit in the Embeddingbag pooling and manual pooling text classifier (please compare the two images),:backhand_index_pointing_down:t2:

Hi @Deepti_Prasad,

Thank you for your keen observation regarding the limitations of EmbeddingBag and manual pooling, particularly how they struggle with deeper semantic relationships like synonyms. You are absolutely right that these techniques often fall short compared to more advanced architectures when dealing with complex context.

However, regarding the specific labeling issues you noticed (e.g., “Lemon and Herb Roasted Chicken” or the “Avocado Toast” inconsistency), it is important to note that the primary focus of these labs is to teach the mechanics of the pipeline, such as preprocessing, batching with collate_fn, and fine-tuning, rather than to build a production-ready food classifier.

The “poor labeling” is actually a known constraint of the dataset used for this pedagogical exercise, and the notebooks explicitly warn about this difference between the training labels (derived from ingredients) and the model input (restricted to titles).

In the “Building a Simple Text Classifier” Lab: The notebook explicitly sets this expectation in the Testing the Best Model on New Examples section:

Note: Remember, the model’s predictions are based only on the words in the recipe’s name. It was never shown the ingredients list, so it has no knowledge of whether fruits or vegetables are the dominant ingredient. A recipe’s name can sometimes be misleading, and the model’s classification will reflect only what it has learned from the title’s text.

It also explains earlier that the ground truth was generated by scanning ingredients (which the model never sees), creating the very disconnect you observed:

…It scanned each recipe’s ingredients for a predefined list of common fruit and vegetable keywords…

In the “Fine Tuning Pre-Trained Text Classifier” Lab: This context is reiterated. The Revisiting Recipe Dataset section reminds us we are using the same subset, and the Testing the Fine-tuned BERT Model section includes the exact same warning:

A recipe’s name can sometimes be misleading, and the model’s classification will reflect only what it has learned from the title’s text.

The takeaway here is the successful implementation of the process (building the dataset class, handling padding, training loops), rather than the quality of the model’s output on this specific, noisy dataset. The fact that the models struggle with “Lemon Chicken” or “Avocado Toast” effectively demonstrates exactly why we need the advanced techniques covered later in the courses.

Best,
Mubsi

1 Like