Commit Graph

314 Commits

Author SHA1 Message Date
Matthew Honnibal
bede11b67c
Improve label management in parser and NER (#2108)
This patch does a few smallish things that tighten up the training workflow a little, and allow memory use during training to be reduced by letting the GoldCorpus stream data properly.

Previously, the parser and entity recognizer read and saved labels as lists, with extra labels noted separately. Lists were used becaue ordering is very important, to ensure that the label-to-class mapping is stable.

We now manage labels as nested dictionaries, first keyed by the action, and then keyed by the label. Values are frequencies. The trick is, how do we save new labels? We need to make sure we iterate over these in the same order they're added. Otherwise, we'll get different class IDs, and the model's predictions won't make sense.

To allow stable sorting, we map the new labels to negative values. If we have two new labels, they'll be noted as having "frequency" -1 and -2. The next new label will then have "frequency" -3. When we sort by (frequency, label), we then get a stable sort.

Storing frequencies then allows us to make the next nice improvement. Previously we had to iterate over the whole training set, to pre-process it for the deprojectivisation. This led to storing the whole training set in memory. This was most of the required memory during training.

To prevent this, we now store the frequencies as we stream in the data, and deprojectivize as we go. Once we've built the frequencies, we can then apply a frequency cut-off when we decide how many classes to make.

Finally, to allow proper data streaming, we also have to have some way of shuffling the iterator. This is awkward if the training files have multiple documents in them. To solve this, the GoldCorpus class now writes the training data to disk in msgpack files, one per document. We can then shuffle the data by shuffling the paths.

This is a squash merge, as I made a lot of very small commits. Individual commit messages below.

* Simplify label management for TransitionSystem and its subclasses

* Fix serialization for new label handling format in parser

* Simplify and improve GoldCorpus class. Reduce memory use, write to temp dir

* Set actions in transition system

* Require thinc 6.11.1.dev4

* Fix error in parser init

* Add unicode declaration

* Fix unicode declaration

* Update textcat test

* Try to get model training on less memory

* Print json loc for now

* Try rapidjson to reduce memory use

* Remove rapidjson requirement

* Try rapidjson for reduced mem usage

* Handle None heads when projectivising

* Stream json docs

* Fix train script

* Handle projectivity in GoldParse

* Fix projectivity handling

* Add minibatch_by_words util from ud_train

* Minibatch by number of words in spacy.cli.train

* Move minibatch_by_words util to spacy.util

* Fix label handling

* More hacking at label management in parser

* Fix encoding in msgpack serialization in GoldParse

* Adjust batch sizes in parser training

* Fix minibatch_by_words

* Add merge_subtokens function to pipeline.pyx

* Register merge_subtokens factory

* Restore use of msgpack tmp directory

* Use minibatch-by-words in train

* Handle retokenization in scorer

* Change back-off approach for missing labels. Use 'dep' label

* Update NER for new label management

* Set NER tags for over-segmented words

* Fix label alignment in gold

* Fix label back-off for infrequent labels

* Fix int type in labels dict key

* Fix int type in labels dict key

* Update feature definition for 8 feature set

* Update ud-train script for new label stuff

* Fix json streamer

* Print the line number if conll eval fails

* Update children and sentence boundaries after deprojectivisation

* Export set_children_from_heads from doc.pxd

* Render parses during UD training

* Remove print statement

* Require thinc 6.11.1.dev6. Try adding wheel as install_requires

* Set different dev version, to flush pip cache

* Update thinc version

* Update GoldCorpus docs

* Remove print statements

* Fix formatting and links [ci skip]
2018-03-19 02:58:08 +01:00
Matthew Honnibal
318c23d318 Increment thinc 2018-03-16 13:12:53 +01:00
Matthew Honnibal
39c50225e8 Update thinc 2018-03-16 03:57:47 +01:00
Matthew Honnibal
7be561c8be Fix thinc requirement 2018-03-16 03:34:12 +01:00
Matthew Honnibal
53df6d867b Require new thinc 2018-03-16 03:20:01 +01:00
Matthew Honnibal
791631f433 Require thinc 6.11.0 2018-03-16 02:51:54 +01:00
Matthew Honnibal
f128e160ea Add missing cytoolz requirement 2018-03-13 13:08:12 +01:00
ines
f5f4de98d1 Version-lock msgpack-python (see #2015) 2018-02-22 16:02:32 +01:00
ines
8c09850354 Version-lock msgpack-python (see #2015) 2018-02-22 13:25:52 +01:00
ines
6bba1db4cc Drop six and related hacks as a dependency 2018-02-18 13:29:56 +01:00
Matthew Honnibal
2b2ce125d5 Fix thinc version pin 2017-12-06 13:23:35 +01:00
Matthew Honnibal
04a92bd75e Pin msgpack-numpy requirement 2017-12-06 03:24:24 +01:00
Matthew Honnibal
5719fd1ce9 Require dev1 of thinc 2017-12-05 10:52:48 +01:00
Matthew Honnibal
716ccbb71e Require thinc 6.10.1 2017-11-15 14:59:34 +01:00
Matthew Honnibal
314f5b9cdb Require thinc 6.10.0 2017-10-28 18:20:10 +00:00
Matthew Honnibal
32b9f3d1a6 Require new thinc 2017-10-03 22:17:31 +02:00
Matthew Honnibal
b49cc8153a Require correct thinc 2017-09-26 10:00:18 -05:00
ines
665cdab58d Port over change from #1126 2017-09-26 16:51:52 +02:00
Matthew Honnibal
8c390e23a2 Require older Cython 2017-09-26 14:14:46 +02:00
ines
68f66aebf8 Use pkg_resources instead of pip for is_package (resolves #1293) 2017-09-16 20:27:59 +02:00
Matthew Honnibal
07cdbd1219 Require thinc 6.8.1, for Windows 2017-09-15 22:47:53 +02:00
Matthew Honnibal
f9ae86b01c Fix requirement 2017-08-18 20:56:53 +02:00
Matthew Honnibal
60d8111245 Require thinc 6.8.1 2017-08-15 03:12:26 -05:00
Matthew Honnibal
ff7418b0d9 Update requirements 2017-07-25 18:58:15 +02:00
Matthew Honnibal
a4dcc96c54 Require thinc bugfix 2017-06-05 04:02:52 -05:00
ines
71954d5fe7 Update Thinc version 2017-06-03 10:32:53 +02:00
ines
f45cd174bf Update Thinc version 2017-06-02 18:48:16 +02:00
Matthew Honnibal
ae8010b526 Move weight serialization to Thinc 2017-06-01 02:56:12 -05:00
Matthew Honnibal
2e364f7ecd Require msgpack 2017-05-29 13:47:29 +02:00
Matthew Honnibal
8c9b3d5ad7 Add mock to requirements 2017-05-20 13:54:31 +02:00
ines
3cc6fe1484 Add pip to requirements.txt and setup.py 2017-05-17 12:04:03 +02:00
Matthew Honnibal
48de4ed49f Require thinc 6.6, and compile the nn_parser module 2017-05-14 01:20:28 +02:00
Ines Montani
40a8f22ca7 Relax version contraint 2017-04-20 15:38:52 +02:00
Gyorgy Orosz
4a06a2572c Using ftfy for handling broken encoded strings. 2017-04-20 13:34:51 +02:00
ines
90cf6b9429 Add pytest to requirements.txt 2017-04-16 20:37:45 +02:00
Matthew Honnibal
eedafd8d82 Fix regex version pin 2017-04-07 17:47:11 +02:00
ines
c691caa9d3 Fix requests version 2017-04-07 17:35:35 +02:00
Matthew Honnibal
a001365c42 Require regex library 2017-04-07 15:43:34 +02:00
ines
387e34a3c5 Update plac version in requirements and setup 2017-03-18 15:14:02 +01:00
ines
4c53eed35a Remove sputnik from dependencies and docs 2017-03-15 17:39:25 +01:00
ines
b62322d602 Add requests to requirements 2017-03-15 17:39:08 +01:00
Matthew Honnibal
cb39b6e337 Require recent thinc 2017-03-11 12:45:22 -06:00
Matthew Honnibal
93ab888d1d Require recent preshed 2017-03-11 12:33:56 -06:00
ines
ffe0f0c6c4 Add dill to requirements 2017-03-08 14:11:54 +01:00
Raphaël Bournhonesque
0c2e5539ce Specify version number for ujson and plac
The required version was specified for plac in requirements.txt but not in setup.py, which could cause a conflicting version error.
Similarly, set the version of ujson in requirements.txt to be the same as in setup.py
2017-01-28 18:38:14 +01:00
Matthew Honnibal
d4e6d4c1c4 Use new thinc 2017-01-16 13:17:14 +01:00
Matthew Honnibal
c9fdd9917c Require older thinc 2017-01-09 10:12:41 -06:00
Matthew Honnibal
7108ad9d80 Require thinc 6.1 2017-01-09 14:37:00 +01:00
Matthew Honnibal
af81ac8bb0 Use thinc 6.0 2016-12-29 11:58:42 +01:00
Matthew Honnibal
7c5fe84b80 Require older preshed, for thinc compatibility. 2016-10-09 12:25:53 +02:00
Matthew Honnibal
d61feffe24 Require new preshed 2016-09-30 18:41:01 +02:00
Rahul Kulhari
afebf9ad9a updated plac version
current new version of plac(0.9.3) is creating problem but it is working <0.9.3
2016-06-10 18:27:02 +05:30
Henning Peters
bb3238bcdd pin numpy to >=1.7, ship headers 2016-04-19 19:50:42 +02:00
Matthew Honnibal
c628908479 * Pin Cython to <0.24, until we fix for new version 2016-04-07 11:51:53 +10:00
Henning Peters
1fe29c6919 cleanup 2016-03-13 18:12:32 +01:00
Henning Peters
5b3b3ebc8e upgrade to latest sputnik 2016-03-08 15:30:17 +01:00
Henning Peters
12d58a7099 remove text-unidecode dependency 2016-02-24 08:01:59 +01:00
Henning Peters
4c9e3c7911 upgrade spuntik, enforce data api via model version constraints 2016-02-14 16:03:17 +01:00
Henning Peters
82c57f21a4 Update requirements.txt 2016-02-10 18:56:21 +01:00
Matthew Honnibal
6d58451a4d * Fix requirement of thinc 2016-02-05 11:50:11 +01:00
Henning Peters
65aeac24cb remove package version constraint 2016-01-21 17:40:51 +01:00
Henning Peters
bc229790ac integrate with sputnik 2016-01-13 19:46:17 +01:00
Matthew Honnibal
e38205a838 * Pin versions to ranges, to escape version lock 2015-12-31 02:09:55 +01:00
Henning Peters
1c4352c42e bump version 2015-12-28 13:53:26 +01:00
Matthew Honnibal
8b61d45ed0 * Fix merge conflicts for headers branch 2015-12-27 17:46:25 +01:00
Henning Peters
a404bfec38 bump preshed version 2015-12-22 22:38:25 +01:00
Henning Peters
46fe3a7327 bump thinc version 2015-12-22 13:21:24 +01:00
Henning Peters
1643e63c31 bump preshed version 2015-12-22 11:23:25 +01:00
Henning Peters
4a1d843682 bump murmurhash version 2015-12-21 21:59:11 +01:00
Henning Peters
c17ce6c119 (re-)include cython sources, murmurhash header discovery 2015-12-21 12:40:44 +01:00
Henning Peters
55bd1469dc add newer sputnik version 2015-12-15 15:34:27 +01:00
Henning Peters
9cde3f37bf add newer sputnik version 2015-12-15 12:23:32 +01:00
Henning Peters
eaadca2bf2 get buildbot running 2015-12-13 14:13:46 +01:00
Henning Peters
7e0757bc5f require newer sputnik version 2015-12-07 07:02:42 +01:00
Henning Peters
9027cef3bc access model via sputnik 2015-12-07 06:01:28 +01:00
Henning Peters
4e98ea4e41 bump version 2015-11-21 19:04:57 +01:00
Henning Peters
919a4f0b04 change data path, add repository 2015-11-18 11:40:46 +01:00
Henning Peters
12de895e60 fix version 2015-11-15 16:38:16 +01:00
Matthew Honnibal
a79dbc5b5d * Fix requirements.txt 2015-11-06 17:35:59 +01:00
Matthew Honnibal
f56209ef2e * Update requirements 2015-11-03 02:40:01 +11:00
Henning Peters
bfde91fa49 add custom download tool (uget), replace wget with uget 2015-10-18 12:35:04 +02:00
maxirmx
1b8fd329b8 Merge remote-tracking branch 'refs/remotes/honnibal/master' 2015-10-13 11:28:17 +03:00
Matthew Honnibal
d74a1e51d7 * Add cloudpickle requirement 2015-10-13 19:05:20 +11:00
maxirmx
3dbec0902f Merge remote-tracking branch 'refs/remotes/honnibal/master'
Conflicts -- pushing preshed 0.42
	requirements.txt
	setup.py
2015-10-13 10:16:16 +03:00
Matthew Honnibal
38109dd912 * Allow preshed v0.42 2015-10-13 13:56:23 +11:00
maxirmx
c1ca220769 Appveyor build
+ push preshed v. 0.42
2015-10-11 23:58:41 +03:00
maxirmx
a0ffb856da Appveyor build
+ requirements.txt
2015-10-11 23:55:38 +03:00
maxirmx
815994a212 MSVC x86-64 Pyton 2.7 dirty build 2015-10-10 17:32:44 +03:00
Matthew Honnibal
f9d2a5b651 * Fix issue #112: Replace unidecode with text-unidecode, to avoid license problems. 2015-09-28 23:40:18 +10:00
Matthew Honnibal
65f3ce6c52 * Require preshed 0.41 2015-07-25 22:36:43 +02:00
Matthew Honnibal
287d90e792 * Use thinc 3.3 2015-07-24 04:52:50 +02:00
Matthew Honnibal
5d595b5a8c * Inc versions 2015-06-30 18:11:06 +02:00
Matthew Honnibal
4944d3ba20 * Update requirement to thinc 3.0 2015-06-28 06:21:20 +02:00
Matthew Honnibal
90a3add8d7 * Require thinc 2.0 2015-06-10 06:57:13 +02:00
Matthew Honnibal
2ef3555d88 * Add ujson to requirements.txt 2015-06-07 03:22:17 +02:00
Matthew Honnibal
a57ced0ead * Pin cython packages to particular versions, so that the current version works even if updates to them are pushed. 2015-06-05 23:51:39 +02:00
Matthew Honnibal
23e2f26535 * Require thinc 1.76 2015-06-05 15:50:05 +02:00
Matthew Honnibal
c50b493c85 * Add pathlib requirement 2015-04-12 07:17:48 +02:00
Matthew Honnibal
dea1245311 * Require advanced version of cymem 2015-02-01 17:04:59 +11:00
Matthew Honnibal
c260180207 * Add six to requirements 2015-02-01 16:24:33 +11:00
Matthew Honnibal
a3955fd8d5 * Require plac 2015-01-31 13:50:53 +11:00
Matthew Honnibal
30a02f2611 * Upd requirements 2015-01-25 23:01:42 +11:00
Matthew Honnibal
0d62236247 * Add numpy to requirements 2015-01-25 02:25:29 +11:00
Matthew Honnibal
7e69e17161 * Upd requirements.txt 2015-01-17 16:20:16 +11:00
Matthew Honnibal
e15b9da7db * Pin preshed to a particular version 2014-12-20 04:01:32 +11:00
Matthew Honnibal
096ef2b199 * Rename external hashing lib, from trustyc to preshed 2014-09-26 18:40:03 +02:00
Matthew Honnibal
ac522e2553 * Switch from own memory class to cymem, in pip 2014-09-17 23:09:24 +02:00
Matthew Honnibal
cab7f63fc2 * Temporarily remove sparsehash requirement 2014-08-20 17:12:19 +02:00
Matthew Honnibal
0c4c47b074 * Add docs requirements 2014-08-20 17:02:54 +02:00
Matthew Honnibal
85df22c379 * Remove murmurhash from requirements 2014-08-18 23:26:20 +02:00
Matthew Honnibal
b9016c4633 * Switch to using sparsehash and murmurhash libraries out of pip 2014-07-25 15:47:27 +01:00
Matthew Honnibal
3f7cbb93e0 * Upd requirements 2014-07-23 17:50:34 +01:00
Matthew Honnibal
0575f16ade * Upd requirements 2014-07-07 07:37:29 +02:00
Matthew Honnibal
ca7045f3f2 * Add build/setup stuff 2014-07-05 20:49:34 +02:00