Skip to main content

Machine Learning libraries for Information Retrieval

Project description

ml4ir Python Quickstart

For more detailed usage documentation check ml4ir.readthedocs.io

Contents

Installation

Using ml4ir as a library

Requirements
  • python3.{6,7} (tf2.0.3 is not available for python3.8)
  • pip3

ml4ir can be installed as a pip package by using the following command

pip3 install ml4ir

This will install ml4ir-0.0.2 (the current version) from PyPI.

Using ml4ir as a toolkit or contributing to ml4ir

Firstly, clone ml4ir

git clone https://github.com/salesforce/ml4ir

You can use and develop on ml4ir either using docker or virtualenv

Docker (Recommended)

Requirements

We have set up a docker-compose.yml file for building and using docker containers to train models.

Change the working directory to the python package

cd path/to/ml4ir/python/

To build the docker image and run unit tests

docker-compose up --build

To only build the ml4ir docker image without running tests

docker-compose build

Virtual Environment

Requirements
  • python3.{6,7} (tf2.0.3 is not available for python3.8)
  • pip3

Change the working directory to the python package

cd path/to/ml4ir/python/

Install virtualenv

pip3 install virtualenv

Create new python3 virtual environment inside your git repo (it's .gitignored, don't worry)

python3 -m venv env/.ml4ir_venv3

Activate virtualenv

source env/.ml4ir_venv3/bin/activate

Install all dependencies

pip3 install --upgrade setuptools
pip install --upgrade pip
pip3 install -r requirements.txt

Set the PYTHONPATH environment variable to point to the python package

export PYTHONPATH=$PYTHONPATH:`pwd`

Note about contributing

pre-commit-hooks are required, and installed as a requirement for contributing to ml4ir. If an error results that they didn't install, execute pre-commit install to install git hooks in your .git/ directory.

Usage

ml4ir as a toolkit

The entrypoint into the training or evaluation functionality of ml4ir is through ml4ir/base/pipeline.py and for application specific overrides, look at `ml4ir/applications/<eg: ranking>/pipeline.py

Pipelines currently supported:

  • ml4ir/applications/ranking/pipeline.py

  • ml4ir/applications/classification/pipeline.py

To run the ml4ir ranking pipeline to train, evaluate and/or test, use

docker-compose run ml4ir \
    python3 ml4ir/applications/ranking/pipeline.py \
    <args>

An example ranking training predict and evaluate pipeline

docker-compose run ml4ir \
	python3 ml4ir/applications/ranking/pipeline.py \
	--data_dir ml4ir/applications/ranking/tests/data/tfrecord \
	--feature_config ml4ir/applications/ranking/tests/data/configs/feature_config.yaml \
	--run_id test \
	--data_format tfrecord \
	--execution_mode train_inference_evaluate

For more examples of usage, check:

ml4ir as a library

To use ml4ir as a deep learning library to build relevance models, look at the following walkthroughs under notebooks/

  • Learning to Rank : The PointwiseRankingDemo notebook walks you through building, training, saving, and the entire life cycle of a RelevanceModel from the bottom up. You can also find details regarding the architecture of ml4ir in it.

  • Text Classification : The EntityPredictionDemo notebook walks you through training a model to predict entity type given a user context and query.

Enter the following command to spin up Jupyter notebook on your browser to run the above notebooks

cd path/to/ml4ir/python/
source env/.ml4ir_venv3/bin/activate
pip3 install notebook
jupyter-notebook

Running Tests

To run all the python based tests under ml4ir

Using docker

docker-compose up

Using virtualenv

python3 -m pytest

To run specific tests,

python3 -m pytest /path/to/test/module

Build

We are using CircleCi for the build process. For code coverage for python, we are using coverage Python coverage scores for each PR are calculated by the build and are available in the "Artifacts" section of the build_test_coverage job.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml4ir-0.0.4.tar.gz (110.1 kB view details)

Uploaded Source

Built Distribution

ml4ir-0.0.4-py3-none-any.whl (155.0 kB view details)

Uploaded Python 3

File details

Details for the file ml4ir-0.0.4.tar.gz.

File metadata

  • Download URL: ml4ir-0.0.4.tar.gz
  • Upload date:
  • Size: 110.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.7

File hashes

Hashes for ml4ir-0.0.4.tar.gz
Algorithm Hash digest
SHA256 aaa210977173f9ee59bb8a6bd6e876c85623cce17d3ce973adf6080164bdb6e6
MD5 7615019d0c8b3f412d310d680939b03c
BLAKE2b-256 e5f8c0437fbe78fecccfd30bc4e561fcb8c41067c21961351c78f30787a41d62

See more details on using hashes here.

File details

Details for the file ml4ir-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ml4ir-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 155.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.7

File hashes

Hashes for ml4ir-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0fec7121de68bff5808a37a81a20c1d0ffd8cb26e96bcb4f51c81492459f7d8
MD5 1b45e82537d85e65a4e681ecb24e63c8
BLAKE2b-256 536d1d52977e020cbd57f2d8f515c0b5f5fe50f84d5f0c5304d08ff87ae507af

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page