Hi Everyone, I am following along the course on page Transformers, what can they do? - Hugging Face LLM Course. I am trying to generate text using HuggingFaceTB/SmolLM2-360M with the paramaters max_length=30, num_return_sequences=2.
It gives me the following error: ValueError: Greedy methods without beam search do not support num_return_sequences different than 1 (got 2).
Would anyone be able to help me understand what it means and how to resolve this issue?
I don’t understand the logic, but this solved the problem.
from transformers import pipeline
generator = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-360M")
generator(
"In this course, we will teach you how to",
max_length=30,
num_return_sequences=2,
do_sample=True,
)
Can you provide certifcate of completion if i finished this course?
Hi @Pizofreude,
I just published two blog posts about recent RL algorithms for reasoning tasks such as GRPO and Dr. GRPO.
You can find them on Medium:
- The Evolution of Policy Optimization: Understanding GRPO, DAPO, and Dr. GRPO’s Theoretical Foundations
- Bridging Theory and Practice: Understanding GRPO Implementation Details in Hugging Face’s TRL Library
I hope you find it helpful in some way.
Thank you,
Jen
I am working on the Transformers, what can they do? section, on the Text Generation section. When I try to run
from transformers import pipeline
generator = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-360M")
generator(
"In this course, we will teach you how to",
max_length=30,
num_return_sequences=2,
)
I get this error: Both max_new_tokens(=256) andmax_length(=15) seem to have been set. max_new_tokens will take precedence.
I read the documentation and it states that max_length “corresponds to the length of the input prompt + max_new_tokens”. Should I just use max_new_tokens instead of max_length?
I tend to use max_new_tokens.
I’ve noticed that the GitHub page for this course doesn’t have a translation in my native language, which is spoken by around 100 million people. I was wondering if spending time translating the page into my local language would provide any benefits for me or others who might be interested in taking the course. If so, I might consider translating other courses as well
Hello! I’ve been trying to get the course commands to run locally on my Mac. I have Apple M4 Pro on 15.6.1, and I have activated the venv.
You can see my pip freeze here:
$ pip freeze | grep -E "transform|torch|tensor"
safetensors==0.6.2
tensorboard==2.20.0
tensorboard-data-server==0.7.2
tensorflow==2.20.0
torch==2.8.0
torchaudio==2.8.0
torchvision==0.23.0
transformers==4.56.1
Python is the one inside the transformers-course/.env/bin/python, and
$ python --version
Python 3.13.7
Do you know what may be the issue here?
>>> from transformers import pipeline
libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
zsh: abort python
I seem to have similar issues with a handful of random import commands… Thank you!
Do you know what may be the issue here?
Python 3.13.7
Python 3.13 or later sometimes cause issues with many libraries highly possibly…
I recommend 3.12 or 3.11.
Unfortunately the same issue applied to python 3.12…
$ python --version
Python 3.12.11
$ pip freeze | grep -E "transform|torch|tensor"
safetensors==0.6.2
tensorboard==2.20.0
tensorboard-data-server==0.7.2
tensorflow==2.20.0
torch==2.8.0
torchaudio==2.8.0
torchvision==0.23.0
transformers==4.56.1
And python 3.11…
$ python3.11
Python 3.11.11 (main, Jul 13 2025, 04:58:55) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from transformers import pipeline
libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
zsh: abort python3.11
Thank you for looking!
Some versions of TensorFlow seem to crash on Mac…
Guess this is the only way?
pip uninstall -y tensorflow tf-keras tf_keras keras onnxruntime
export USE_TF=0 # prevents TF checks inside transformers
python -c "from transformers import pipeline; print('import ok')"
Yes, lowering the tensorflow version worked thank you!
This combination worked for me.
$ pip freeze | grep -E "tensor|numpy|protobuf"
numpy==2.1.3
protobuf==5.29.5
safetensors==0.6.2
tensorboard==2.19.0
tensorboard-data-server==0.7.2
tensorflow==2.19.1
In section “A bit of Transformer history” this part
January 2022: InstructGPT, a version of GPT-3 that was trained to follow instructions better This list is far from comprehensive, and is just meant to highlight a few of the different kinds of Transformer models. Broadly, they can be grouped into three categories:
is not followed by, what I believe, is the correct one:
GPT-like (also called auto-regressive Transformer models)
BERT-like (also called auto-encoding Transformer models)
T5-like (also called sequence-to-sequence Transformer models)
Is saving my progress possible in this course and the others?
Any answers?
When I use the Colab notebook, I get an error on the second cell. Does anyone know how to fix it?
from transformers import pipeline
classifier = pipeline(“sentiment-analysis”)
classifier(“I’ve been waiting for a HuggingFace course my whole life.”)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _getattr_(self, name)
2248 try:
→ 2249 module = self._get_module(self._class_to_module[name])
2250 value = getattr(module, name)
/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
2482 except Exception as e:
→ 2483 raise e
2484
/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
2480 try:
→ 2481 return importlib.import_module(“.” + module_name, self._name_)
2482 except Exception as e:
/usr/lib/python3.12/importlib/_init_.py in import_module(name, package)
89 level += 1
—> 90 return _bootstrap._gcd_import(name[level:], package, level)
91
/usr/lib/python3.12/importlib/_bootstrap.py in _gcd_import(name, package, level)
/usr/lib/python3.12/importlib/_bootstrap.py in _find_and_load(name, import_)
/usr/lib/python3.12/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
/usr/lib/python3.12/importlib/_bootstrap.py in _load_unlocked(spec)
/usr/lib/python3.12/importlib/_bootstrap_external.py in exec_module(self, module)
/usr/lib/python3.12/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
/usr/local/lib/python3.12/dist-packages/transformers/pipelines/_init_.py in
26 from ..feature_extraction_utils import FeatureExtractionMixin
—> 27 from ..image_processing_utils import BaseImageProcessor
28 from ..models.auto.configuration_auto import AutoConfig
/usr/local/lib/python3.12/dist-packages/transformers/image_processing_utils.py in
33 )
—> 34 from .processing_utils import ImagesKwargs, Unpack
35 from .utils import (
/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py in
62 from .utils.chat_template_utils import _get_template_variables, render_jinja_template
—> 63 from .utils.type_validators import (
64 device_validator,
/usr/local/lib/python3.12/dist-packages/transformers/utils/type_validators.py in
7 from ..tokenization_utils_base import PaddingStrategy, TruncationStrategy
----> 8 from ..video_utils import VideoMetadataType
9 from .generic import TensorType
/usr/local/lib/python3.12/dist-packages/transformers/video_utils.py in
48 if is_torchvision_available():
—> 49 from torchvision import io as torchvision_io
50
/usr/local/lib/python3.12/dist-packages/torchvision/_init_.py in
7 from . import extension # usort:skip # noqa: F401
----> 8 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip
9
/usr/local/lib/python3.12/dist-packages/torchvision/models/_init_.py in
1 from .alexnet import *
----> 2 from .convnext import *
3 from .densenet import *
/usr/local/lib/python3.12/dist-packages/torchvision/models/convnext.py in
9 from ..ops.misc import Conv2dNormActivation, Permute
—> 10 from ..ops.stochastic_depth import StochasticDepth
11 from ..transforms._presets import ImageClassification
/usr/local/lib/python3.12/dist-packages/torchvision/ops/_init_.py in
22 from .misc import Conv2dNormActivation, Conv3dNormActivation, FrozenBatchNorm2d, MLP, Permute, SqueezeExcitation
—> 23 from .poolers import MultiScaleRoIAlign
24 from .ps_roi_align import ps_roi_align, PSRoIAlign
/usr/local/lib/python3.12/dist-packages/torchvision/ops/poolers.py in
9 from ..utils import _log_api_usage_once
—> 10 from .roi_align import roi_align
11
/usr/local/lib/python3.12/dist-packages/torchvision/ops/roi_align.py in
6 from torch import nn, Tensor
----> 7 from torch._dynamo.utils import is_compile_supported
8 from torch.jit.annotations import BroadcastingList2
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/_init_.py in
12
—> 13 from . import (
14 aot_compile,
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/aot_compile.py in
14 import torch.fx
—> 15 from torch._dynamo.convert_frame import GraphRuntimeEnv
16 from torch._dynamo.graph_utils import _graph_device_type
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/convert_frame.py in
61 from torch._dynamo.distributed import get_compile_pg
—> 62 from torch._dynamo.symbolic_convert import TensorifyState
63 from torch._guards import compile_context, CompileContext, CompileId, tracing
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/symbolic_convert.py in
53 from torch._dynamo.dynamo_profiler import DynamoProfilerState, FunctionTraceTiming
—> 54 from torch._dynamo.exc import ObservedException, TensorifyScalarRestartAnalysis
55 from torch._guards import InlinedCodeCache, tracing, TracingContext
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/exc.py in
43 from . import config
—> 44 from .utils import counters
45
/usr/local/lib/python3.12/dist-packages/torch/_dynamo/utils.py in
69 import torch._functorch.config
—> 70 import torch.fx.experimental.symbolic_shapes
71 import torch.utils._pytree as pytree
/usr/local/lib/python3.12/dist-packages/torch/fx/experimental/symbolic_shapes.py in
79 from torch.utils._python_dispatch import is_traceable_wrapper_subclass
—> 80 from torch.utils._sympy.functions import (
81 Application,
/usr/local/lib/python3.12/dist-packages/torch/utils/_sympy/functions.py in
187 # not, this can potentially cause correctness issues.
→ 188 class FloorDiv(sympy.Function):
189 “”"
/usr/local/lib/python3.12/dist-packages/torch/utils/_sympy/functions.py in FloorDiv()
210
→ 211 def _sympystr(self, printer: sympy.printing.StrPrinter) → str:
212 base = printer.parenthesize(self.base, PRECEDENCE[“Atom”] - 0.5)
AttributeError: module ‘sympy’ has no attribute ‘printing’
The above exception was the direct cause of the following exception:
ModuleNotFoundError Traceback (most recent call last)
/tmp/ipykernel_3167/711506748.py in <cell line: 0>()
----> 1 from transformers import pipeline
2
3 classifier = pipeline(“sentiment-analysis”)
4 classifier(“I’ve been waiting for a HuggingFace course my whole life.”)
/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _getattr_(self, name)
2335 ) from e
2336 else:
→ 2337 raise ModuleNotFoundError(
2338 f"Could not import module ‘{name}’. Are this object’s requirements defined correctly?"
2339 ) from e
ModuleNotFoundError: Could not import module ‘pipeline’. Are this object’s requirements defined correctly?

