Annif ver 1.3.1 - Neural Network model

28 views
Skip to first unread message

Parthasarathi Mukhopadhyay

unread,
Jun 1, 2025, 6:27:49 PMJun 1
to Annif Users
I was trying Annif version 1.3.1 in Python 3.11 venv for a combined ddc+lcsh project.

All the constituent models are working fine individually (SVC, OmikujiB, FastText)  including the Basic Ensemble. But the Neural Network model is throwing some warnings/errors like this:

echo "Against injustice : the new economics of Amartya Sen / edited by Reiko Gotoh, Paul Dumouchel. ## Introduction / Reiko Gotoh and Paul Dumouchel -- Economics, law, and ethics / Amartya Sen -- Neorepublicanism and Sen's economic, legal, and ethical desiderata / Philip Pettit -- The Prajâpati test : response to Amartya Sen / Marcel Hénaff -- The power of a democratic public / Philip Pettit -- The challenge of gender justice / Martha C. Nussbaum -- Gift, market, and social justice / Marcel Hénaff -- Justice and public reciprocity / Reiko Gotoh -- Reasoning with preferences? / John Broome -- Conceptions of individual rights and freedom in welfare economics : a re-examination / Prasanta K. Pattanaik and Yongsheng Xu -- On applying synthetic indices of multidimensional well-being : health and income inequalities in France, Germany, Italy, and the United Kingdom / Andrea Brandolini -- Assessing children's capabilities : operationalizing metrics for evaluating music programs with poor children in Brazilian primary schools / Flavio Comim -- The search for socially sustainable development : conceptual and methodological issues / Jean-Luc Dubois -- Response / Amartya Sen." | annif suggest lcsh-ddc-svc
<http://dewey.info/class/170/e23/> Ethics. 170 0.3539
<http://dewey.info/class/338.9/e23/> Development economics. 338.9 0.2878
<http://dewey.info/class/302.13/e23/> Social choice. 302.13 0.2845
<http://dewey.info/class/330.1556/e23/> Social choice. 330.1556 0.2833
<http://dewey.info/class/792.0233/e23/> Motion pictures—Production and direction. 792.0233 0.2673
<http://dewey.info/class/541.345/e23/> Colloids. 541.345 0.2668
<http://dewey.info/class/572.88/e23/> RNA—Metabolism. 572.88 0.2668
<http://dewey.info/class/343.08/7/e23/> Foreign trade regulation$vCongresses. 343.08/7 0.2668
<http://dewey.info/class/820.9001/e23/> Epic literature, English. 820.9001 0.2662
<http://dewey.info/class/539.7/21/e23/> Particles (Nuclear physics) -- Experiments. 539.7/21 0.2661

(annif-venv) psm@psm-dlisku:~/annif-v1_3$ echo "Against injustice : the new economics of Amartya Sen / edited by Reiko Gotoh, Paul Dumouchel. ## Introduction / Reiko Gotoh and Paul Dumouchel -- Economics, law, and ethics / Amartya Sen -- Neorepublicanism and Sen's economic, legal, and ethical desiderata / Philip Pettit -- The Prajâpati test : response to Amartya Sen / Marcel Hénaff -- The power of a democratic public / Philip Pettit -- The challenge of gender justice / Martha C. Nussbaum -- Gift, market, and social justice / Marcel Hénaff -- Justice and public reciprocity / Reiko Gotoh -- Reasoning with preferences? / John Broome -- Conceptions of individual rights and freedom in welfare economics : a re-examination / Prasanta K. Pattanaik and Yongsheng Xu -- On applying synthetic indices of multidimensional well-being : health and income inequalities in France, Germany, Italy, and the United Kingdom / Andrea Brandolini -- Assessing children's capabilities : operationalizing metrics for evaluating music programs with poor children in Brazilian primary schools / Flavio Comim -- The search for socially sustainable development : conceptual and methodological issues / Jean-Luc Dubois -- Response / Amartya Sen." | annif suggest lcsh-ddc-nn
2025-06-02 03:49:08.950989: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1748816348.960328   18520 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1748816348.963070   18520 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered

2025-06-01T22:19:10.625Z INFO  [omikuji::model] Loading model from data/projects/lcsh-ddc-omikujiB/omikuji-model...
2025-06-01T22:19:10.625Z INFO  [omikuji::model] Loading model settings from data/projects/lcsh-ddc-omikujiB/omikuji-model/settings.json...
2025-06-01T22:19:10.625Z INFO  [omikuji::model] Loaded model settings Settings { n_features: 340016, classifier_loss_type: Hinge }...
2025-06-01T22:19:10.625Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree0.cbor...
2025-06-01T22:19:10.721Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree1.cbor...
2025-06-01T22:19:10.821Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree2.cbor...
2025-06-01T22:19:10.915Z INFO  [omikuji::model] Loaded model with 3 trees; it took 0.29s
2025-06-02 03:49:16.821469: E external/local_xla/xla/stream_executor/cuda/cuda_driver.cc:152] failed call to cuInit: INTERNAL: CUDA error: Failed call to cuInit: UNKNOWN ERROR (303)
/home/psm/annif-v1_3/annif-venv/lib/python3.10/site-packages/keras/src/models/functional.py:241: UserWarning: The structure of `inputs` doesn't match the expected structure.
Expected: ['input_layer']
Received: inputs=Tensor(shape=(1, 213879, 3))
  warnings.warn(msg)

<http://dewey.info/class/170/e23/> Ethics. 170 0.1648
<http://dewey.info/class/338.9/e23/> Development economics. 338.9 0.1090
<http://dewey.info/class/547.05/e23/> Organometallic chemistry . 547.05 0.0537
<http://dewey.info/class/330.1556/e23/> Social choice. 330.1556 0.0082


CUDA driver errors are okay as this laptop has no GPU though I tried these two but no effect :

CUDA_VISIBLE_DEVICES="" | export TF_CPP_MIN_LOG_LEVEL=2


But the input type mismatch appears to be serious though it is producing LCSH labels and DDC class numbers.

Am I missing something here (installation or training dataset structuring). I have deployed 200K records for all major models but so far only 5K for the NN model.

Thanks and regards

Parthasarathi Mukhopadhyay

Professor, Department of Library and Information Science,

University of Kalyani, Kalyani - 741 235 (WB), India

https://orcid.org/0000-0003-0717-9413

juho.i...@helsinki.fi

unread,
Jun 2, 2025, 6:53:37 AMJun 2
to Annif Users
Hello Parthasarathi!

Thank you for letting us know!

We are actually seeing the same warning in some of our Annif instances since rebuilding the Docker image on May 21st. This is due to the Keras library (a subdependency of TensorFlow) being upgraded from version 3.9.2 to 3.10.0 in that build.

It seems in Keras 3.10.0 an unintentional change was introduced related to this: https://github.com/keras-team/keras/issues/21328 And there are also a bunch of other issues/PRs related to this, most recently this: https://github.com/keras-team/keras/pull/21341

Currently Annif gives the inputs argument of Model *not* as a list, which according to the documentation, is correct usage. I think we can expect a patch release of Keras quite soon, which will remove of the warning.

In the meantime, I think you could get rid of the warning by downgrading Keras with

    pip install --upgrade keras==3.9.2

Also, maybe you could check the suggestion results with both Keras versions, 3.9.2 and 3.10.0 and report here for others? After all, it is only a warning that is shown, and it could be that the suggestion results are actually not affected by the underlying issue.

PS For Annif, CUDA is (currently) unnecessary, so the warnings about CUDA could be removed by just uninstalling it from the virtual environment. But maybe you are needing it for something else.

Best regards,
-Juho

Parthasarathi Mukhopadhyay

unread,
Jun 3, 2025, 12:07:02 AMJun 3
to Annif Users
Hello Juho,

Thanks for your continued guidance!

I've downgraded to Keras 3.9.2 (with TensorFlow 2.18.0 as prescribed). Here's the system information:

pip show tensorflow
Name: tensorflow
Version: 2.18.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: pack...@tensorflow.org
License: Apache 2.0
Location: /home/psm/annif-v1_3/annif-venv/lib/python3.10/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, ml-dtypes, numpy, opt-einsum, packaging, protobuf, requests, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
Required-by:
(annif-venv) psm@psm-dlisku:~/annif-v1_3$ pip show keras
Name: keras
Version: 3.9.2
Summary: Multi-backend Keras
Home-page:
Author:
Author-email: Keras team <keras...@googlegroups.com>
License: Apache License 2.0
Location: /home/psm/annif-v1_3/annif-venv/lib/python3.10/site-packages
Requires: absl-py, h5py, ml-dtypes, namex, numpy, optree, packaging, rich
Required-by: tensorflow

I then cleared and rebuilt the existing lcsh-ddc-nn project. The first attempt resulted in a segmentation fault, but the second attempt was successful.

Here's the result with Keras 3.9.2 for the same book:

echo "Against injustice : the new economics of Amartya Sen / edited by Reiko Gotoh, Paul Dumouchel. ## Introduction / Reiko Gotoh and Paul Dumouchel -- Economics, law, and ethics / Amartya Sen -- Neorepublicanism and Sen's economic, legal, and ethical desiderata / Philip Pettit -- The Prajâpati test : response to Amartya Sen / Marcel Hénaff -- The power of a democratic public / Philip Pettit -- The challenge of gender justice / Martha C. Nussbaum -- Gift, market, and social justice / Marcel Hénaff -- Justice and public reciprocity / Reiko Gotoh -- Reasoning with preferences? / John Broome -- Conceptions of individual rights and freedom in welfare economics : a re-examination / Prasanta K. Pattanaik and Yongsheng Xu -- On applying synthetic indices of multidimensional well-being : health and income inequalities in France, Germany, Italy, and the United Kingdom / Andrea Brandolini -- Assessing children's capabilities : operationalizing metrics for evaluating music programs with poor children in Brazilian primary schools / Flavio Comim -- The search for socially sustainable development : conceptual and methodological issues / Jean-Luc Dubois -- Response / Amartya Sen." | annif suggest lcsh-ddc-nn
2025-06-02 23:54:19.516625: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1748888659.525961   13058 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1748888659.528898   13058 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2025-06-02T18:24:21.176Z INFO  [omikuji::model] Loading model from data/projects/lcsh-ddc-omikujiB/omikuji-model...
2025-06-02T18:24:21.176Z INFO  [omikuji::model] Loading model settings from data/projects/lcsh-ddc-omikujiB/omikuji-model/settings.json...
2025-06-02T18:24:21.176Z INFO  [omikuji::model] Loaded model settings Settings { n_features: 340016, classifier_loss_type: Hinge }...
2025-06-02T18:24:21.176Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree0.cbor...
2025-06-02T18:24:21.268Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree1.cbor...
2025-06-02T18:24:21.361Z INFO  [omikuji::model] Loading tree from data/projects/lcsh-ddc-omikujiB/omikuji-model/tree2.cbor...
2025-06-02T18:24:21.452Z INFO  [omikuji::model] Loaded model with 3 trees; it took 0.28s
2025-06-02 23:54:27.302920: E external/local_xla/xla/stream_executor/cuda/cuda_driver.cc:152] failed call to cuInit: INTERNAL: CUDA error: Failed call to cuInit: UNKNOWN ERROR (303)
<http://dewey.info/class/338.9/e23/> Development economics. 338.9 0.2911
<http://dewey.info/class/170/e23/> Ethics. 170 0.1931
<http://dewey.info/class/792.0233/e23/> Motion pictures—Production and direction. 792.0233 0.1524

Here's an overview of the improvements:

1. The warning "The structure of inputs doesn't match the expected structure. Expected: ['input_layer'] Received: inputs=Tensor(shape=(1, 213879, 3))" is now gone.
2. The results have improved significantly. Previously, for the same book, the suggestions were:


<http://dewey.info/class/170/e23/> Ethics. 170 0.1648
<http://dewey.info/class/338.9/e23/> Development economics. 338.9 0.1090
<http://dewey.info/class/547.05/e23/> Organometallic chemistry . 547.05 0.0537
<http://dewey.info/class/330.1556/e23/> Social choice. 330.1556 0.0082


Now, "Development economics" is the top suggestion, which is much more accurate for the content of the book.

Please explain the following part of your previous answer: "PS For Annif, CUDA is (currently) unnecessary, so the warnings about CUDA could be removed by just uninstalling it from the virtual environment. But maybe you are needing it for something else."

I attempted to uninstall TensorFlow and install tensorflow-cpu to eliminate the CUDA-related warnings. However, this produced errors during training, so I reverted back to using the full TensorFlow package.

Regards

- Parthasarathi




--
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/03182450-e718-4eaa-8ca1-c3f757c89a28n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages