Skip to main content

Run a AllenNLP trained model, and serve it with WebAPI.

Project description

allennlp-runmodel

Run a AllenNLP trained model, and serve it with WebAPI.

Usage

Run the program

Execute the program in terminator, the option --help will show help message:

$ allennlp-runmodel --help
Usage: allennlp-runmodel [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...

  Start a webservice for running AllenNLP models.

Options:
  -V, --version
  -h, --host TEXT                 TCP/IP host for HTTP server.  [default:
                                  localhost]
  -p, --port INTEGER              TCP/IP port for HTTP server.  [default:
                                  8000]
  -a, --path TEXT                 File system path for HTTP server Unix domain
                                  socket. Listening on Unix domain sockets is
                                  not supported by all operating systems.
  -l, --logging-config FILE       Path to logging configuration file (JSON,
                                  YAML or INI) (ref: https://docs.python.org/l
                                  ibrary/logging.config.html#logging-config-
                                  dictschema)
  -v, --logging-level [critical|fatal|error|warn|warning|info|debug|notset]
                                  Sets the logging level, only affected when
                                  `--logging-config` not specified.  [default:
                                  info]
  --help                          Show this message and exit.

Commands:
  load  Load a pre-trained AllenNLP model from it's archive file, and put
        it...

and

$ allennlp-runmodel load --help
Usage: allennlp-runmodel load [OPTIONS] ARCHIVE

  Load a pre-trained AllenNLP model from it's archive file, and put it into
  the webservice contrainer.

Options:
  -m, --model-name TEXT           Model name used in URL. eg: http://xxx.xxx.x
                                  xx.xxx:8000/?model=model_name
  -t, --num-threads INTEGER       Sets the number of OpenMP threads used for
                                  parallelizing CPU operations. [default: 4
                                  (on this machine)]
  -w, --max-workers INTEGER       Uses a pool of at most max_workers threads
                                  to execute calls asynchronously. [default:
                                  num_threads/cpu_count (1 on this machine)]
  -w, --worker-type [process|thread]
                                  Sets the workers execute in thread or
                                  process.  [default: process]
  -d, --cuda-device INTEGER       If CUDA_DEVICE is >= 0, the model will be
                                  loaded onto the corresponding GPU. Otherwise
                                  it will be loaded onto the CPU.  [default:
                                  -1]
  -e, --predictor-name TEXT       Optionally specify which `Predictor`
                                  subclass; otherwise, the default one for the
                                  model will be used.
  --help                          Show this message and exit.

load sub-command can be called many times to load multiple models.

eg:

allennlp-runmodel  --port 8080 load --model-name model1 /path/of/model1.tar.gz load --model-name model2 /path/of/model2.tar.gz

Make prediction from HTTP client

curl \
  --header "Content-Type: application/json" \
  --request POST \
  --data '{"premise":"Two women are embracing while holding to go packages.","hypothesis":"The sisters are hugging goodbye while holding to go packages after just eating lunch."}' \
  http://localhost:8080/?model=model1

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

allennlp-runmodel-0.2.0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

allennlp_runmodel-0.2.0.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file allennlp-runmodel-0.2.0.1.tar.gz.

File metadata

  • Download URL: allennlp-runmodel-0.2.0.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for allennlp-runmodel-0.2.0.1.tar.gz
Algorithm Hash digest
SHA256 f01207ee936a0af793d157ab26bb28eeb99d2e48d34a0af689016ac7b9d0fbf8
MD5 094c42a6e617f022b5d43b5906812407
BLAKE2b-256 60f9be0e405e11e0f60b8be168df8fe93bb99c0c0b82a2f30fd58e13d2f91239

See more details on using hashes here.

File details

Details for the file allennlp_runmodel-0.2.0.1-py3-none-any.whl.

File metadata

  • Download URL: allennlp_runmodel-0.2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for allennlp_runmodel-0.2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4643e717e6560bf4bdd3c2aae3b05767516306feb55fe9045cd99932473c9b1
MD5 5f4bf4938baec1a74ce604cd3d1396d2
BLAKE2b-256 61b1d1028a8198e9d776219560656b0617f5763c10c6935882aa53f2732806bf

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page