Skip to main content

Inspire Classifier

About

INSPIRE package aimed to automatically classify the new papers that are added to INSPIRE, such as if they are core or not.

The current implementation uses the ULMfit approach. Universal Language Model Fine-tuning, is a method for training text classifiers by first pre-training a language model on a large corpus to learn general language features (in this case a pre-loaded model, which was trained using the WikiText-103 dataset is used). The pre-trained model is then fine-tuned on the title and abstract of the INSPIRE dataset before training the classifier on top.

Package Usage

from inspire_classifier import Classifier

classifier = Classifier(model_path="PATH/TO/MODEL.h5")

title = "Search for new physics in high-energy particle collisions"
abstract = "We present results from a search for beyond..."

result = classifier.predict_coreness(title, abstract)
print(result) --> {'prediction': 'core', 'scores': {'rejected': 0.1, 'non_core': 0.3, 'core': 0.6}}

Installation for local usage and Training:

  • Install and activate python 3.11 environment (for example using pyenv)
  • Install poetry: pip install poetry==1.8.3
  • Run poetry install: poetry install

Train new classifier model

1. Gather training data

Set the environment variables for inspire-prod es database and run the create_dataset.py file, passing the range of years. This will create a inspire_classifier_dataset.pkl, containing the label (core, non-core, rejected) as well as the title and abstract of the fetched records. This data will be used in the next step to train the model. Make sure the generated file is called inspire_classifier_dataset.pkl!

export ES_USERNAME=XXXX
export ES_PASSWORD=XXXX

poetry run python scripts/create_dataset.py --year-from $YEAR_FROM --month-from $MONTH_FROM --year-to $YEAR_TO --month-to $MONTH_TO

($MONTH_FROM and $MONTH_TO are optional parameters)

2. Run training and validate model

The train_classifier.py script will run the commands to train and validate a new model. Configurations changes like the amount of training epochs as well as the train-test split can be adjusted here. In short, the script first splits the pkl file from the first step into a training and a test dataset inside the classifier/data folder. The training set is then used to train the model, while the test set is used to evaluate the model after the training is finished. The model will be saved into classifier/models/language_model/finetuned_language_model_encoder.h5

poetry run python scripts/train_classifier.py

3. Upload the model to CERN S3

In order to use the new model in production upload it to CERN S3 and follow this writeup

Release files for inspire-classifier 2.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inspire-classifier 2.0.5
File Size Uploaded
inspire_classifier-2.0.5.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for inspire-classifier 2.0.5
File Interpreter ABI Platform
inspire_classifier-2.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / inspire_classifier-2.0.5.tar.gz

Download URL inspire_classifier-2.0.5.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2e10b160b3e9db54c0e14124074fced2c777bdad1d81a7fd45964c5ee0eae21a
BLAKE2b-256 checksum
How to use checksums
b339cd5baa1c1b77810c95e122f55c45d47aac99f1fde1ecc022fd1ffc2ce146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / inspire_classifier-2.0.5-py3-none-any.whl

Download URL inspire_classifier-2.0.5-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4013e3a7019b8b55ef59ad0f81474e4285af8dd3407076017b9338a42081dbd
BLAKE2b-256 checksum
How to use checksums
10ae1293fa3cc868a910640f5315a4681deb68ff2fd387965eb4f56ec4c7b77a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.21

1 release file

0.0.20

1 release file

0.0.19

1 release file

0.0.18

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page