https://github.com/facebookresearch/pytext
https://pytext.readthedocs.io/en/master/
https://pytext.readthedocs.io/en/master/train_your_first_model.html
(pytext) $ pytext
Usage: pytext [OPTIONS] COMMAND [ARGS]...
Configs can be passed by file or directly from json. If neither --config-
file or --config-json is passed, attempts to read the file from stdin.
Example:
pytext train < demos/docnn.json
Options:
--config-file TEXT
--config-json TEXT
--help Show this message and exit.
Commands:
export Convert a pytext model snapshot to a caffe2 model.
predict Start a repl executing examples against a caffe2 model.
test Test a trained model snapshot.
train Train a model and save the best snapshot.
训练数据:
/Users/huihui/git/pytext/tests/data/train_data_tiny.tsv
/Users/huihui/git/pytext/tests/data/test_data_tiny.tsv
参数设置:/Users/huihui/git/pytext/demo/configs/docnn.json
(pytext) $ cat demo/configs/docnn.json
{
"version": 8,
"task": {
"DocumentClassificationTask": {
"data": {
"source": {
"TSVDataSource": {
"field_names": ["label", "slots", "text"],
"train_filename": "tests/data/train_data_tiny.tsv",
"test_filename": "tests/data/test_data_tiny.tsv",
"eval_filename": "tests/data/test_data_tiny.tsv"
}
}
},
"model": {
"DocModel": {
"representation": {
"DocNNRepresentation": {}
}
}
}
}
}
}
测试结果