2017-03-18 14:24:50 +00:00
|
|
|
|
//- 💫 DOCS > USAGE > COMMAND LINE INTERFACE
|
|
|
|
|
|
|
|
|
|
include ../../_includes/_mixins
|
|
|
|
|
|
|
|
|
|
p
|
|
|
|
|
| As of v1.7.0, spaCy comes with new command line helpers to download and
|
|
|
|
|
| link models and show useful debugging information. For a list of available
|
2017-08-14 10:41:06 +00:00
|
|
|
|
| commands, type #[code spacy --help].
|
2017-05-22 10:28:58 +00:00
|
|
|
|
|
|
|
|
|
+infobox("⚠️ Deprecation note")
|
|
|
|
|
| As of spaCy 2.0, the #[code model] command to initialise a model data
|
|
|
|
|
| directory is deprecated. The command was only necessary because previous
|
|
|
|
|
| versions of spaCy expected a model directory to already be set up. This
|
|
|
|
|
| has since been changed, so you can use the #[+api("cli#train") #[code train]]
|
|
|
|
|
| command straight away.
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+h(2, "download") Download
|
|
|
|
|
|
|
|
|
|
p
|
|
|
|
|
| Download #[+a("/docs/usage/models") models] for spaCy. The downloader finds the
|
|
|
|
|
| best-matching compatible version, uses pip to download the model as a
|
|
|
|
|
| package and automatically creates a
|
|
|
|
|
| #[+a("/docs/usage/models#usage") shortcut link] to load the model by name.
|
|
|
|
|
| Direct downloads don't perform any compatibility checks and require the
|
|
|
|
|
| model name to be specified with its version (e.g., #[code en_core_web_sm-1.2.0]).
|
|
|
|
|
|
2017-08-14 10:41:06 +00:00
|
|
|
|
+code(false, "bash", "$").
|
|
|
|
|
spacy download [model] [--direct]
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code model]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Model name or shortcut (#[code en], #[code de], #[code vectors]).
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --direct], #[code -d]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Force direct download of exact model version.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Show help message and available arguments.
|
|
|
|
|
|
2017-05-22 10:28:58 +00:00
|
|
|
|
+aside("Downloading best practices")
|
2017-05-21 11:23:39 +00:00
|
|
|
|
| The #[code download] command is mostly intended as a convenient,
|
|
|
|
|
| interactive wrapper – it performs compatibility checks and prints
|
|
|
|
|
| detailed messages in case things go wrong. It's #[strong not recommended]
|
|
|
|
|
| to use this command as part of an automated process. If you know which
|
|
|
|
|
| model your project needs, you should consider a
|
|
|
|
|
| #[+a("/docs/usage/models#download-pip") direct download via pip], or
|
|
|
|
|
| uploading the model to a local PyPi installation and fetching it straight
|
|
|
|
|
| from there. This will also allow you to add it as a versioned package
|
|
|
|
|
| dependency to your project.
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+h(2, "link") Link
|
|
|
|
|
|
|
|
|
|
p
|
|
|
|
|
| Create a #[+a("/docs/usage/models#usage") shortcut link] for a model,
|
|
|
|
|
| either a Python package or a local directory. This will let you load
|
2017-05-20 23:13:05 +00:00
|
|
|
|
| models from any location using a custom name via
|
|
|
|
|
| #[+api("spacy#load") #[code spacy.load()]].
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
2017-06-04 11:55:00 +00:00
|
|
|
|
+infobox("Important note")
|
|
|
|
|
| In spaCy v1.x, you had to use the model data directory to set up a shortcut
|
|
|
|
|
| link for a local path. As of v2.0, spaCy expects all shortcut links to
|
|
|
|
|
| be #[strong loadable model packages]. If you want to load a data directory,
|
|
|
|
|
| call #[+api("spacy#load") #[code spacy.load()]] or
|
|
|
|
|
| #[+api("language#from_disk") #[code Language.from_disk()]] with the path,
|
|
|
|
|
| or use the #[+api("cli#package") #[code package]] command to create a
|
|
|
|
|
| model package.
|
|
|
|
|
|
2017-08-14 10:41:06 +00:00
|
|
|
|
+code(false, "bash", "$").
|
|
|
|
|
spacy link [origin] [link_name] [--force]
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code origin]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Model name if package, or path to local directory.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code link_name]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Name of the shortcut link to create.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --force], #[code -f]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Force overwriting of existing link.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Show help message and available arguments.
|
|
|
|
|
|
|
|
|
|
+h(2, "info") Info
|
|
|
|
|
|
|
|
|
|
p
|
|
|
|
|
| Print information about your spaCy installation, models and local setup,
|
|
|
|
|
| and generate #[+a("https://en.wikipedia.org/wiki/Markdown") Markdown]-formatted
|
|
|
|
|
| markup to copy-paste into #[+a(gh("spacy") + "/issues") GitHub issues].
|
|
|
|
|
|
2017-03-18 17:19:50 +00:00
|
|
|
|
+code(false, "bash").
|
2017-08-14 10:41:06 +00:00
|
|
|
|
spacy info [--markdown]
|
|
|
|
|
spacy info [model] [--markdown]
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code model]
|
|
|
|
|
+cell positional
|
2017-05-20 10:58:05 +00:00
|
|
|
|
+cell A model, i.e. shortcut link, package name or path (optional).
|
2017-03-18 14:24:50 +00:00
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --markdown], #[code -md]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Print information as Markdown.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Show help message and available arguments.
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+h(2, "convert") Convert
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
|
|
|
|
p
|
2017-04-07 11:27:55 +00:00
|
|
|
|
| Convert files into spaCy's #[+a("/docs/api/annotation#json-input") JSON format]
|
|
|
|
|
| for use with the #[code train] command and other experiment management
|
|
|
|
|
| functions. The right converter is chosen based on the file extension of
|
|
|
|
|
| the input file. Currently only supports #[code .conllu].
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
2017-08-14 10:41:06 +00:00
|
|
|
|
+code(false, "bash", "$").
|
|
|
|
|
spacy convert [input_file] [output_dir] [--n-sents] [--morphology]
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+cell #[code input_file]
|
2017-03-21 10:19:21 +00:00
|
|
|
|
+cell positional
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+cell Input file.
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code output_dir]
|
|
|
|
|
+cell positional
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+cell Output directory for converted JSON file.
|
2017-03-21 10:19:21 +00:00
|
|
|
|
|
|
|
|
|
+row
|
2017-05-20 23:13:05 +00:00
|
|
|
|
+cell #[code --n-sents], #[code -n]
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+cell option
|
|
|
|
|
+cell Number of sentences per document.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --morphology], #[code -m]
|
|
|
|
|
+cell option
|
|
|
|
|
+cell Enable appending morphology to tags.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
2017-03-21 10:19:21 +00:00
|
|
|
|
+cell flag
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+cell Show help message and available arguments.
|
|
|
|
|
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+h(2, "train") Train
|
|
|
|
|
|
|
|
|
|
p
|
2017-03-26 13:56:15 +00:00
|
|
|
|
| Train a model. Expects data in spaCy's
|
|
|
|
|
| #[+a("/docs/api/annotation#json-input") JSON format].
|
2017-03-26 13:33:48 +00:00
|
|
|
|
|
2017-08-14 10:41:06 +00:00
|
|
|
|
+code(false, "bash", "$").
|
|
|
|
|
spacy train [lang] [output_dir] [train_data] [dev_data] [--n-iter] [--n-sents] [--use-gpu] [--no-tagger] [--no-parser] [--no-entities]
|
2017-03-26 13:33:48 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code lang]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Model language.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code output_dir]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Directory to store model in.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code train_data]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Location of JSON-formatted training data.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code dev_data]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Location of JSON-formatted dev data (optional).
|
|
|
|
|
|
|
|
|
|
+row
|
2017-05-20 23:13:05 +00:00
|
|
|
|
+cell #[code --n-iter], #[code -n]
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+cell option
|
2017-05-26 12:02:38 +00:00
|
|
|
|
+cell Number of iterations (default: #[code 20]).
|
2017-03-26 13:33:48 +00:00
|
|
|
|
|
|
|
|
|
+row
|
2017-05-26 12:02:38 +00:00
|
|
|
|
+cell #[code --n-sents], #[code -ns]
|
2017-05-20 23:13:05 +00:00
|
|
|
|
+cell option
|
|
|
|
|
+cell Number of sentences (default: #[code 0]).
|
|
|
|
|
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+row
|
2017-06-04 21:45:14 +00:00
|
|
|
|
+cell #[code --use-gpu], #[code -g]
|
|
|
|
|
+cell option
|
2017-05-20 23:13:05 +00:00
|
|
|
|
+cell Use GPU.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --no-tagger], #[code -T]
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+cell flag
|
|
|
|
|
+cell Don't train tagger.
|
|
|
|
|
|
|
|
|
|
+row
|
2017-05-20 23:13:05 +00:00
|
|
|
|
+cell #[code --no-parser], #[code -P]
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+cell flag
|
|
|
|
|
+cell Don't train parser.
|
|
|
|
|
|
|
|
|
|
+row
|
2017-05-26 12:02:38 +00:00
|
|
|
|
+cell #[code --no-entities], #[code -N]
|
2017-03-26 13:33:48 +00:00
|
|
|
|
+cell flag
|
|
|
|
|
+cell Don't train NER.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Show help message and available arguments.
|
2017-04-07 11:27:55 +00:00
|
|
|
|
|
2017-05-26 12:02:38 +00:00
|
|
|
|
+h(3, "train-hyperparams") Environment variables for hyperparameters
|
|
|
|
|
|
|
|
|
|
p
|
|
|
|
|
| spaCy lets you set hyperparameters for training via environment variables.
|
|
|
|
|
| This is useful, because it keeps the command simple and allows you to
|
|
|
|
|
| #[+a("https://askubuntu.com/questions/17536/how-do-i-create-a-permanent-bash-alias/17537#17537") create an alias]
|
|
|
|
|
| for your custom #[code train] command while still being able to easily
|
|
|
|
|
| tweak the hyperparameters. For example:
|
|
|
|
|
|
|
|
|
|
+code(false, "bash").
|
2017-05-26 12:04:31 +00:00
|
|
|
|
parser_hidden_depth=2 parser_maxout_pieces=1 train-parser
|
2017-05-26 12:02:38 +00:00
|
|
|
|
|
|
|
|
|
+under-construction
|
|
|
|
|
|
|
|
|
|
+table(["Name", "Description", "Default"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code dropout_from]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.2]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code dropout_to]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.2]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code dropout_decay]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.0]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code batch_from]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 1]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code batch_to]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 64]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code batch_compound]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 1.001]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code token_vector_width]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 128]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code embed_size]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 7500]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code parser_maxout_pieces]
|
|
|
|
|
+cell
|
2017-05-26 12:04:31 +00:00
|
|
|
|
+cell #[code 2]
|
2017-05-26 12:02:38 +00:00
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code parser_hidden_depth]
|
|
|
|
|
+cell
|
2017-05-26 12:04:31 +00:00
|
|
|
|
+cell #[code 1]
|
2017-05-26 12:02:38 +00:00
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code hidden_width]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 128]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code learn_rate]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.001]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code optimizer_B1]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.9]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code optimizer_B2]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 0.999]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code optimizer_eps]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 1e-08]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code L2_penalty]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 1e-06]
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code grad_norm_clip]
|
|
|
|
|
+cell
|
|
|
|
|
+cell #[code 1.0]
|
|
|
|
|
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+h(2, "package") Package
|
|
|
|
|
|
|
|
|
|
p
|
2017-04-16 18:36:59 +00:00
|
|
|
|
| Generate a #[+a("/docs/usage/saving-loading#generating") model Python package]
|
2017-04-16 11:37:24 +00:00
|
|
|
|
| from an existing model data directory. All data files are copied over.
|
|
|
|
|
| If the path to a meta.json is supplied, or a meta.json is found in the
|
|
|
|
|
| input directory, this file is used. Otherwise, the data can be entered
|
2017-05-22 10:28:58 +00:00
|
|
|
|
| directly from the command line. The required file templates are downloaded
|
|
|
|
|
| from #[+src(gh("spacy-dev-resources", "templates/model")) GitHub] to make
|
|
|
|
|
| sure you're always using the latest versions. This means you need to be
|
|
|
|
|
| connected to the internet to use this command.
|
2017-04-07 11:27:55 +00:00
|
|
|
|
|
2017-08-14 10:41:06 +00:00
|
|
|
|
+code(false, "bash", "$").
|
|
|
|
|
spacy package [input_dir] [output_dir] [--meta] [--force]
|
2017-04-07 11:27:55 +00:00
|
|
|
|
|
|
|
|
|
+table(["Argument", "Type", "Description"])
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code input_dir]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Path to directory containing model data.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code output_dir]
|
|
|
|
|
+cell positional
|
|
|
|
|
+cell Directory to create package folder in.
|
|
|
|
|
|
2017-04-16 11:37:24 +00:00
|
|
|
|
+row
|
2017-08-14 14:45:42 +00:00
|
|
|
|
+cell #[code --meta-path], #[code -m]
|
2017-04-16 11:37:24 +00:00
|
|
|
|
+cell option
|
|
|
|
|
+cell Path to meta.json file (optional).
|
|
|
|
|
|
2017-08-14 14:45:42 +00:00
|
|
|
|
+row
|
|
|
|
|
+cell #[code --create-meta], #[code -c]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell
|
|
|
|
|
| Create a meta.json file on the command line, even if one already
|
|
|
|
|
| exists in the directory.
|
|
|
|
|
|
2017-04-07 11:27:55 +00:00
|
|
|
|
+row
|
|
|
|
|
+cell #[code --force], #[code -f]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Force overwriting of existing folder in output directory.
|
|
|
|
|
|
|
|
|
|
+row
|
|
|
|
|
+cell #[code --help], #[code -h]
|
|
|
|
|
+cell flag
|
|
|
|
|
+cell Show help message and available arguments.
|