Annif 1.2 with spaCy

22 views
Skip to first unread message

Parthasarathi Mukhopadhyay

unread,
Oct 9, 2024, 2:05:33 AM10/9/24
to Annif Users
Dear all

Today morning I attempted upgrading my Annif instance version 1.1.0 to version 1.2.0.
I'm using spaCy for some of my Annif projects.

The upgradation went on smmothly but reported error during annif run / annif list-projects commands.
The error was:

ImportError: cannot import name 'triu' from 'scipy.linalg' (/home/psm/annif/annif-venv/lib/python3.10/site-packages/scipy/linalg/__init__.py)
INFO: 127.0.0.1:58004 - "GET /v1/projects HTTP/1.1" 500 Internal Server Error

 
A bit of Googling landed me with this finding:

The scipy.linalg functions tri, triu & tril are deprecated and will be removed in SciPy 1.13.

But Annif 1.2.0 is using scipy version 1.13. However, I downgraded scipy to version 1.10.1

pip install scipy==1.10.1


This time Annif (annif run) produced this error:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.

annif 1.2.0 requires scipy<1.14.0,>=1.13.1, but you have scipy 1.10.1 which is incompatible.


Fortunately after downgrading Annif is running as expected and I was able to complete retraining of the neural network network backend of a project successfully.

Hope this little adjustment won't create any issues in future.

Thanks and regards

Parthasarathi Mukhopadhyay
University of Kalyani, Kalyani - 741 235 (WB), India
https://orcid.org/0000-0003-0717-9413

juho.i...@helsinki.fi

unread,
Oct 15, 2024, 9:05:27 AM10/15/24
to Annif Users
Hi Parthasarathi,

I tried if I could find the cause for your upgrade problem, but could not reproduce it.

When I upgrade from Annif 1.1.0 to 1.2.0, my test project using NN-ensemble (having TFIDF as its base project) and spacy(en_core_web_sm) analyzer, I get no errors. I used Python 3.10.15.

Some points that might be helpful:

1. After upgrading Annif with

    pip install --upgrade annif

I needed to reinstall/upgrade NN ensemble dependencies before I could retrain the NN-ensemble project, so I ran

    pip install annif[nn,spacy]

This also made sure Spacy is up-to-date.

2. Previously, some installation errors have been due to old versions of pip or other package management software, and they have been resolved by running

    pip install --upgrade pip setuptools wheel

3. Also completely removing the old Python virtual environment and creating a new one before installing new Annif version can be tried.

-Juho

Parthasarathi Mukhopadhyay

unread,
Oct 15, 2024, 11:52:51 AM10/15/24
to Annif Users
Thanks Juho for the guidance.

I'm still getting a kind of warning during the evaluation of the models Omikuji, SVC and NN (but not for fasttext), though it is working it seems:

annif eval sdg-nn /home/psm/Desktop/psm-all/sdg-iimc/set-final2/test-1332.tsv
/home/psm/annif/annif-venv/lib/python3.10/site-packages/sklearn/base.py:376: InconsistentVersionWarning: Trying to unpickle estimator TfidfTransformer from version 1.4.2 when using version 1.5.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/home/psm/annif/annif-venv/lib/python3.10/site-packages/sklearn/base.py:376: InconsistentVersionWarning: Trying to unpickle estimator TfidfVectorizer from version 1.4.2 when using version 1.5.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/home/psm/annif/annif-venv/lib/python3.10/site-packages/sklearn/base.py:376: InconsistentVersionWarning: Trying to unpickle estimator LinearSVC from version 1.4.2 when using version 1.5.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations
  warnings.warn(
2024-10-15T15:44:35.761Z INFO [omikuji::model] Loading model from data/projects/sdg-omikujiB/omikuji-model...
2024-10-15T15:44:35.762Z INFO [omikuji::model] Loading model settings from data/projects/sdg-omikujiB/omikuji-model/settings.json...
2024-10-15T15:44:35.762Z INFO [omikuji::model] Loaded model settings Settings { n_features: 455704, classifier_loss_type: Hinge }...
2024-10-15T15:44:35.762Z INFO [omikuji::model] Loading tree from data/projects/sdg-omikujiB/omikuji-model/tree0.cbor...
2024-10-15T15:44:35.782Z INFO [omikuji::model] Loading tree from data/projects/sdg-omikujiB/omikuji-model/tree1.cbor...
2024-10-15T15:44:35.803Z INFO [omikuji::model] Loading tree from data/projects/sdg-omikujiB/omikuji-model/tree2.cbor...
2024-10-15T15:44:35.823Z INFO [omikuji::model] Loaded model with 3 trees; it took 0.06s
Precision (doc avg):           0.5641
Recall (doc avg):             0.9867
F1 score (doc avg):           0.6741
Precision (subj avg):         0.4520
Recall (subj avg):             0.9593
F1 score (subj avg):           0.5963
Precision (weighted subj avg): 0.5345
Recall (weighted subj avg):   0.9715
F1 score (weighted subj avg): 0.6733
Precision (microavg):         0.4421
Recall (microavg):             0.9715
F1 score (microavg):           0.6077
F1@5:                         0.6757
NDCG:                         0.9740
NDCG@5:                       0.9742
NDCG@10:                       0.9740
Precision@1:                   0.9595
Precision@3:                   0.5843
Precision@5:                   0.5652
True positives:               1433
False positives:               1808
False negatives:               42
Documents evaluated:           1332

The idea of creating different venv for different Annif versions is a great idea to avoid version conflicts of the components in the testing phase. I'll try that.

Regards

--
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 on the web visit https://groups.google.com/d/msgid/annif-users/39b78227-8044-4621-97df-c45316f41847n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages