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

Metadata

Release files for inspire-classifier 2.0.6

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.6
File Size Uploaded
inspire_classifier-2.0.6.tar.gz 9.2 kB Details

Built distribution (wheel)

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

Total release size: 22.3 kB

Release files / inspire_classifier-2.0.6.tar.gz

Download URL inspire_classifier-2.0.6.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
318659525f15640a0f63d925883fc9a0b0ab7f223f5a4bc6b63787742d40a649
BLAKE2b-256 checksum
How to use checksums
d34092a9af4ef543ae68322f7958629cef2a9acc5b614dbc08875c7da67d535a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL inspire_classifier-2.0.6-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9aaa319666d7bcecad93de48c5551f8ce9ff78d166005a08bdb8467d68e1b2af
BLAKE2b-256 checksum
How to use checksums
e4a7f35c5e1817ff6096321cccf8acea7391f862991cbbcc7cb58d5e80fb3949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2.0.6 This release

2 release files

2.0.5

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