External Publication
Visit Post

LLM Course code errors

Hugging Face Forums [Unofficial] March 4, 2026
Source

I’m following the LLM Course. I’m trying the tutorial code snippets in Google colab. I get the following errors in machine translation, text summarization and named entity recognition. Any help to resolve them will be much appreciated.



Machine Translation

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_365/531379416.py in <cell line: 0>()
      1 from transformers import pipeline
      2
----> 3 translator = pipeline("translation", model="Helsinki-NLP/opus-mt-fr-en")
      4
      5 translator("Ce cours est produit par Hugging Face.")


/usr/local/lib/python3.12/dist-packages/transformers/pipelines/base.py in check_task(self, task)
   1352                 task = "translation"
   1353                 return task, targeted_task, (tokens[1], tokens[3])
-> 1354             raise KeyError(f"Invalid translation task {task}, use 'translation_XX_to_YY' format")
   1355
   1356         raise KeyError(

KeyError: "Invalid translation task translation, use 'translation_XX_to_YY' format"

Text Summarization

KeyError                                  Traceback (most recent call last)




/tmp/ipykernel_365/3730791013.py in <cell line: 0>()
      1 from transformers import pipeline
      2
----> 3 summarizer = pipeline("summarization")
      4 summarizer(
      5     """

2 frames

/usr/local/lib/python3.12/dist-packages/transformers/pipelines/base.py in check_task(self, task)
   1354             raise KeyError(f"Invalid translation task {task}, use 'translation_XX_to_YY' format")
   1355
-> 1356         raise KeyError(
   1357             f"Unknown task {task}, available tasks are {self.get_supported_tasks() + ['translation_XX_to_YY']}"
   1358         )

KeyError: "Unknown task summarization, available tasks are ['any-to-any', 'audio-classification', 'automatic-speech-recognition', 'depth-estimation', 'document-question-answering', 'feature-extraction', 'fill-mask', 'image-classification', 'image-feature-extraction', 'image-segmentation', 'image-text-to-text', 'image-to-image', 'keypoint-matching', 'mask-generation', 'ner', 'object-detection', 'question-answering', 'sentiment-analysis', 'table-question-answering', 'text-classification', 'text-generation', 'text-to-audio', 'text-to-speech', 'token-classification', 'video-classification', 'visual-question-answering', 'vqa', 'zero-shot-audio-classification', 'zero-shot-classification', 'zero-shot-image-classification', 'zero-shot-object-detection', 'translation_XX_to_YY']"

Named Entity Recognition

TypeError                                 Traceback (most recent call last)




/tmp/ipykernel_365/3280479951.py in <cell line: 0>()
      1 from transformers import pipeline
      2
----> 3 ner = pipeline("ner", grouped_entities=True)
      4
      5 ner("My name is Sylvain and I work at Hugging Face in Brooklyn.")

2 frames

/usr/local/lib/python3.12/dist-packages/transformers/pipelines/base.py in _init _(self, model, tokenizer, feature_extractor, image_processor, processor, task, device, binary_output, **kwargs) 919 self._batch_size = kwargs.pop(“batch_size”, None) 920 self._num_workers = kwargs.pop(“num_workers”, None) → 921 self._preprocess_params, self._forward_params, self._postprocess_params = self._sanitize_parameters(**kwargs) 922 923 # In processor only mode, we can get the modality processors from the processor

TypeError: TokenClassificationPipeline._sanitize_parameters() got an unexpected keyword argument ‘grouped_entities’

Discussion in the ATmosphere

Loading comments...