Error during hyperparameter optimization

5 views
Skip to first unread message

Uldis Bojars

unread,
Oct 27, 2025, 3:04:15 PM (2 days ago) Oct 27
to Annif Users
Hi,

I am encountering an error during the hyperparameter optimization for Annif 1.4 with the MLLM backend:

[W 2025-10-27 20:51:04,722] Trial 0 failed with parameters: {'min_samples_leaf': 26, 'max_leaf_nodes': 703, 'max_samples': 0.6243407608424335} because of the following error: TypeError("'NoneType' object is not subscriptable").
Traceback (most recent call last):
  File "/Users/captsolo/.../annif_dataset_fulltext_lv/.venv/lib/python3.12/site-packages/optuna/study/_optimize.py", line 201, in _run_trial
    value_or_values = func(trial)
                      ^^^^^^^^^^^
  File "/Users/captsolo/.../annif_dataset_fulltext_lv/.venv/lib/python3.12/site-packages/annif/backend/hyperopt.py", line 67, in _objective_wrapper
    return cls.objective(trial, cls.args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/captsolo/.../annif_dataset_fulltext_lv/.venv/lib/python3.12/site-packages/annif/backend/mllm.py", line 59, in objective
    model.fit(args["train_x"], args["train_y"])
              ~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

I am getting this error for all trials.

Could anyone suggest how to fix it?

Best regards,
Uldis

juho.i...@helsinki.fi

unread,
Oct 28, 2025, 4:42:56 AM (yesterday) Oct 28
to Annif Users
Hi Uldis!

This is mostly a hunch, but this error can be related to MacOS and parallel procesing; there was a change regarding this in Annif 1.4: https://github.com/NatLibFi/Annif/pull/873

Just to confirm: Does the project you are optimizing work otherwise (suggest calls) and did the hyperopt command for the same project work with Annif 1.3?

Maybe someone using MacOS could report whether they can use annif hyperopt with MLLM and/or other backends?

A workaround for the actual or possible bug could be to use only one process: use --jobs 1 option in the hyperopt command.

-Juho

Uldis Bojars

unread,
Oct 28, 2025, 10:21:30 AM (yesterday) Oct 28
to juho.i...@helsinki.fi, Annif Users
Hi Juho!

You are right – hyperopt works fine with the --jobs 1 option.

Is there anything I can do to help diagnose the problem?

Just to confirm: Does the project you are optimizing work otherwise (suggest calls) and did the hyperopt command for the same project work with Annif 1.3?

Yes, suggest calls work just fine. The previous Annif version we were using was 1.2. The hyperopt command worked for the same project with Annif 1.2. 

To other MacOS users: what is your experience with hyperparameter optimization with Annif 1.4?

Uldis


--
You received this message because you are subscribed to the Google Groups "Annif Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to annif-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/annif-users/3f81f86f-ed10-4ca1-8a4c-31c224689852n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages