MCPcopy
hub / github.com/explosion/spaCy / train_cli

Function train_cli

spacy/cli/train.py:26–73  ·  view source on GitHub ↗

Train or update a spaCy pipeline. Requires data in spaCy's binary format. To convert data from other formats, use the `spacy convert` command. The config file includes all settings and hyperparameters used during training. To override settings in the config, e.g. settings that point

(
    # fmt: off
    ctx: typer.Context,  # This is only used to read additional arguments
    config_path: Path = Arg(
        ..., help="Path to config file", exists=True, allow_dash=True
    ),
    output_path: Optional[Path] = Opt(
        None,
        "--output",
        "--output-path",
        "-o",
        help="Output directory to store trained pipeline in",
    ),
    code_path: Optional[Path] = Opt(
        None,
        "--code",
        "-c",
        help="Path to Python file with additional code (registered functions) to be imported",
    ),
    verbose: bool = Opt(
        False,
        "--verbose",
        "-V",
        "-VV",
        help="Display more information for debugging purposes",
    ),
    use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
    # fmt: on
)

Source from the content-addressed store, hash-verified

24 "train", context_settings={"allow_extra_args": True, "ignore_unknown_options": True}
25)
26def train_cli(
27 # fmt: off
28 ctx: typer.Context, # This is only used to read additional arguments
29 config_path: Path = Arg(
30 ..., help="Path to config file", exists=True, allow_dash=True
31 ),
32 output_path: Optional[Path] = Opt(
33 None,
34 "--output",
35 "--output-path",
36 "-o",
37 help="Output directory to store trained pipeline in",
38 ),
39 code_path: Optional[Path] = Opt(
40 None,
41 "--code",
42 "-c",
43 help="Path to Python file with additional code (registered functions) to be imported",
44 ),
45 verbose: bool = Opt(
46 False,
47 "--verbose",
48 "-V",
49 "-VV",
50 help="Display more information for debugging purposes",
51 ),
52 use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
53 # fmt: on
54):
55 """
56 Train or update a spaCy pipeline. Requires data in spaCy's binary format. To
57 convert data from other formats, use the `spacy convert` command. The
58 config file includes all settings and hyperparameters used during training.
59 To override settings in the config, e.g. settings that point to local
60 paths or that you want to experiment with, you can override them as
61 command line options. For instance, --training.batch_size 128 overrides
62 the value of "batch_size" in the block "[training]". The --code argument
63 lets you pass in a Python file that's imported before training. It can be
64 used to register custom functions and architectures that can then be
65 referenced in the config.
66
67 DOCS: https://spacy.io/api/cli#train
68 """
69 if verbose:
70 util.logger.setLevel(logging.DEBUG)
71 overrides = parse_config_overrides(ctx.args)
72 import_code(code_path)
73 train(config_path, output_path, use_gpu=use_gpu, overrides=overrides)
74
75
76def train(

Callers

nothing calls this directly

Calls 3

parse_config_overridesFunction · 0.85
import_codeFunction · 0.85
trainFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…