File size: 9,180 Bytes
5472d34 f5757aa 5472d34 f5757aa 5472d34 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
title: "Demo spancat in a new pipeline (Span Categorization)"
description: "A minimal demo spancat project for spaCy v3"
# Variables can be referenced across the project.yml using ${vars.var_name}
vars:
name: "placing_holocaust"
lang: "en"
annotations_file: "annotated_data_spans.jsonl"
train: "train"
dev: "dev"
test: "test"
version: "0.0.1"
# Set a random seed
seed: 0
# Set your GPU ID, -1 is CPU
gpu_id: -1
vectors_model_md: "en_core_web_md"
vectors_model_lg: "en_core_web_lg"
# These are the directories that the project needs. The project CLI will make
# sure that they always exist.
directories: ["assets", "corpus", "configs", "training", "scripts", "packages"]
# Assets that should be downloaded or available in the directory. We're shipping
# them with the project, so they won't have to be downloaded.
assets:
- dest: "assets/train.jsonl"
description: "Training data. For this project, they were chunked into sentences."
- dest: "assets/dev.jsonl"
description: "Validation data. For this project, they were chunked into sentences."
- dest: "assets/test.jsonl"
description: "Testing data. For this project, they were chunked into sentences."
- dest: "assets/annotated_data.json/"
description: "All data, including those without annotations because they are negative examples."
- dest: "assets/annotated_data_spans.jsonl"
description: "This is just the data that contained examples of span annotations."
- dest: "corpus/train.spacy"
description: "Training data in serialized format."
- dest: "corpus/dev.spacy"
description: "Validation data in serialized format."
- dest: "corpus/test.spacy"
description: "Testing data in serialized format."
- dest: "gold-training-data/*"
description: "The original outputs from Prodigy, the annotation software used."
- dest: "notebooks/*"
description: "A collection of notebooks for testing different features of the project."
- dest: "configs/*"
description: "A collection of config files used for training the spaCy models."
# Workflows are sequences of commands (see below) executed in order. You can
# run them via "spacy project run [workflow]". If a commands's inputs/outputs
# haven't changed, it won't be re-run.
workflows:
all-sm-sents:
- convert-sents
- split
- create-config-sm
- train-sm
- evaluate-sm
# all-trf:
# - download
# - convert
# - create-config
# - train-with-vectors
# - evaluate
# Project commands, specified in a style similar to CI config files (e.g. Azure
# pipelines). The name is the command name that lets you trigger the command
# via "spacy project run [command] [path]". The help message is optional and
# shown when executing "spacy project run [optional command] [path] --help".
commands:
#### DOWNLOADING VECTORS #####
- name: "download-lg"
help: "Download a spaCy model with pretrained vectors"
script:
- "python -m spacy download ${vars.vectors_model_lg}"
- name: "download-md"
help: "Download a spaCy model with pretrained vectors"
script:
- "python -m spacy download ${vars.vectors_model_md}"
#### PREPROCESSING #####
- name: "convert"
help: "Convert the data to spaCy's binary format"
script:
- "python scripts/convert.py ${vars.lang} assets/${vars.train}.jsonl corpus"
- "python scripts/convert.py ${vars.lang} assets/${vars.dev}.jsonl corpus"
- "python scripts/convert.py ${vars.lang} assets/${vars.test}.jsonl corpus"
deps:
- "assets/${vars.train}.jsonl"
- "assets/${vars.dev}.jsonl"
- "assets/${vars.test}.jsonl"
- "scripts/convert.py"
outputs:
- "corpus/train.spacy"
- "corpus/dev.spacy"
- "corpus/test.spacy"
- name: "convert-sents"
help: "Convert the data to to sentences before converting to spaCy's binary format"
script:
- "python scripts/convert_sents.py ${vars.lang} assets/${vars.train}.jsonl corpus"
- "python scripts/convert_sents.py ${vars.lang} assets/${vars.dev}.jsonl corpus"
- "python scripts/convert_sents.py ${vars.lang} assets/${vars.test}.jsonl corpus"
deps:
- "assets/${vars.train}.jsonl"
- "assets/${vars.dev}.jsonl"
- "assets/${vars.test}.jsonl"
- "scripts/convert.py"
outputs:
- "corpus/train.spacy"
- "corpus/dev.spacy"
- "corpus/test.spacy"
- name: "split"
help: "Split data into train/dev/test sets"
script:
- "python scripts/split.py assets/${vars.annotations_file}"
deps:
- "scripts/split.py"
outputs:
- "assets/train.jsonl"
- "assets/dev.jsonl"
- "assets/test.jsonl"
#### CONFIG CREATIONS #####
- name: "create-config-sm"
help: "Create a new config with a spancat pipeline component"
script:
- "python -m spacy init fill-config configs/base_config_sm.cfg configs/config_sm.cfg"
deps:
- configs/base_config_sm.cfg
outputs:
- "configs/config.cfg"
#### TRAINING #####
### small ###
- name: "train-sm"
help: "Train the spancat model"
script:
- >-
python -m spacy train configs/config_sm.cfg --output training/sm/
--paths.train corpus/train.spacy --paths.dev corpus/dev.spacy
--training.eval_frequency 50
--training.patience 0
--gpu-id ${vars.gpu_id}
--system.seed ${vars.seed}
deps:
- "configs/config_lg.cfg"
- "corpus/train.spacy"
- "corpus/dev.spacy"
outputs:
- "training/model-best"
### medium ###
- name: "train-md"
help: "Train the spancat model with vectors"
script:
- >-
python -m spacy train configs/config_md.cfg --output training/md/
--paths.train corpus/train.spacy --paths.dev corpus/dev.spacy
--training.eval_frequency 50
--training.patience 0
--gpu-id ${vars.gpu_id}
--initialize.vectors ${vars.vectors_model_md}
--system.seed ${vars.seed}
--components.tok2vec.model.embed.include_static_vectors true
deps:
- "configs/config_md.cfg"
- "corpus/train.spacy"
- "corpus/dev.spacy"
outputs:
- "training/model-best"
### large ###
- name: "train-lg"
help: "Train the spancat model with vectors"
script:
- >-
python -m spacy train configs/config_lg.cfg --output training/lg/
--paths.train corpus/train.spacy --paths.dev corpus/dev.spacy
--training.eval_frequency 50
--training.patience 0
--gpu-id ${vars.gpu_id}
--initialize.vectors ${vars.vectors_model_lg}
--system.seed ${vars.seed}
--components.tok2vec.model.embed.include_static_vectors true
deps:
- "configs/config_lg.cfg"
- "corpus/train.spacy"
- "corpus/dev.spacy"
outputs:
- "training/model-best"
### transformer ###
- name: "train-trf"
help: "Train the spancat model"
script:
- >-
python -m spacy train configs/config_trf.cfg --output training/trf/
--paths.train corpus/train.spacy --paths.dev corpus/dev.spacy
--training.patience 100
--gpu-id ${vars.gpu_id}
--system.seed ${vars.seed}
deps:
- "configs/config.cfg"
- "corpus/train.spacy"
- "corpus/dev.spacy"
outputs:
- "training/model-best"
#### EVALUATION #####
### small ###
- name: "evaluate-sm"
help: "Evaluate the model and export metrics"
script:
- "python -m spacy evaluate training/sm/model-best corpus/test.spacy --output training/sm/metrics.json"
deps:
- "corpus/test.spacy"
- "training/sm/model-best"
outputs:
- "training/sm/metrics.json"
### medium ###
- name: "evaluate-md"
help: "Evaluate the model and export metrics"
script:
- "python -m spacy evaluate training/md/model-best corpus/test.spacy --output training/md/metrics.json"
deps:
- "corpus/test.spacy"
- "training/md/model-best"
outputs:
- "training/md/metrics.json"
### large ###
- name: "evaluate-lg"
help: "Evaluate the model and export metrics"
script:
- "python -m spacy evaluate training/lg/model-best corpus/test.spacy --output training/lg/metrics.json"
deps:
- "corpus/test.spacy"
- "training/lg/model-best"
outputs:
- "training/lg/metrics.json"
#### PACKAGING #####
- name: "build-table"
help: "builds a nice table from the metrics for README.md"
script:
- "python scripts/build-table.py"
- name: "readme"
help: "builds a nice table from the metrics for README.md"
script:
- "python scripts/readme.py"
- name: package
help: "Package the trained model as a pip package"
script:
- "python -m spacy package training/model-best packages --name ${vars.name} --version ${vars.version} --force"
deps:
- "training/model-best"
outputs_no_cache:
- "packages/${vars.lang}_${vars.name}-${vars.version}/dist/${vars.lang}_${vars.name}-${vars.version}.tar.gz"
- name: clean
help: "Remove intermediary directories"
script:
- "rm -rf corpus/*"
- "rm -rf training/*"
- "rm -rf metrics/*"
|