QuickStart¶
There is a bunch of great pre-trained NLP models in DeepPavlov. Each model is determined by its config file.
List of models is available on the doc page or in
the deeppavlov.configs (Python):
from deeppavlov import configs
When you’re decided on the model (+ config file), there are two ways to train, evaluate and infer it:
via Command line interface (CLI) and
via Python.
Before making choice of an interface, install model’s package requirements (CLI):
python -m deeppavlov install <config_path>
where
<config_path>is path to the chosen model’s config file (e.g.deeppavlov/configs/ner/slotfill_dstc2.json) or just name without .json extension (e.g.slotfill_dstc2)
Command line interface (CLI)¶
To get predictions from a model interactively through CLI, run
python -m deeppavlov interact <config_path> [-d]
-ddownloads required data – pretrained model files and embeddings (optional).
You can train it in the same simple way:
python -m deeppavlov train <config_path> [-d]Dataset will be downloaded regardless of whether there was
-dflag or not.To train on your own data you need to modify dataset reader path in the train section doc. The data format is specified in the corresponding model doc page.
There are even more actions you can perform with configs:
python -m deeppavlov <action> <config_path> [-d]
<action>can be
downloadto download model’s data (same as-d),
trainto train the model on the data specified in the config file,
evaluateto calculate metrics on the same dataset,
interactto interact via CLI,
riseapito run a REST API server (see docs),
interactbotto run as a Telegram bot (see docs),
interactmsbotto run a Miscrosoft Bot Framework server (see docs),
predictto get prediction for samples from stdin or from <file_path> if-f <file_path>is specified.
<config_path>specifies path (or name) of model’s config file
-ddownloads required data
Python¶
To get predictions from a model interactively through Python, run
from deeppavlov import build_model model = build_model(<config_path>, download=True) # get predictions for 'input_text1', 'input_text2' model(['input_text1', 'input_text2'])
where
download=Truedownloads required data from web – pretrained model files and embeddings (optional),
<config_path>is path to the chosen model’s config file (e.g."deeppavlov/configs/ner/ner_ontonotes_bert_mult.json") ordeeppavlov.configsattribute (e.g.deeppavlov.configs.ner.ner_ontonotes_bert_multwithout quotation marks).
You can train it in the same simple way:
from deeppavlov import train_model model = train_model(<config_path>, download=True)
download=Truedownloads pretrained model, therefore the pretrained model will be, first, loaded and then train (optional).Dataset will be downloaded regardless of whether there was
-dflag or not.To train on your own data you need to modify dataset reader path in the train section doc. The data format is specified in the corresponding model doc page.
You can also calculate metrics on the dataset specified in your config file:
from deeppavlov import evaluate_model model = evaluate_model(<config_path>, download=True)
There are also available integrations with various messengers, see Telegram Bot doc page and others in the Integrations section for more info.