-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add POS tagging and Phrase chunking token classification examples (#6457
) * Add more token classification examples * POS tagging example * Phrase chunking example * PR review fixes * Add conllu to third party list (used in token classification examples)
- Loading branch information
Showing
10 changed files
with
473 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ pandas | |
nlp | ||
fire | ||
pytest | ||
conllu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if ! [ -f ./dev.txt ]; then | ||
echo "Downloading CONLL2003 dev dataset...." | ||
curl -L -o ./dev.txt 'https://github.com/davidsbatista/NER-datasets/raw/master/CONLL2003/valid.txt' | ||
fi | ||
|
||
if ! [ -f ./test.txt ]; then | ||
echo "Downloading CONLL2003 test dataset...." | ||
curl -L -o ./test.txt 'https://github.com/davidsbatista/NER-datasets/raw/master/CONLL2003/test.txt' | ||
fi | ||
|
||
if ! [ -f ./train.txt ]; then | ||
echo "Downloading CONLL2003 train dataset...." | ||
curl -L -o ./train.txt 'https://github.com/davidsbatista/NER-datasets/raw/master/CONLL2003/train.txt' | ||
fi | ||
|
||
export MAX_LENGTH=200 | ||
export BERT_MODEL=bert-base-uncased | ||
export OUTPUT_DIR=chunker-model | ||
export BATCH_SIZE=32 | ||
export NUM_EPOCHS=3 | ||
export SAVE_STEPS=750 | ||
export SEED=1 | ||
|
||
python3 run_ner.py \ | ||
--task_type Chunk \ | ||
--data_dir . \ | ||
--model_name_or_path $BERT_MODEL \ | ||
--output_dir $OUTPUT_DIR \ | ||
--max_seq_length $MAX_LENGTH \ | ||
--num_train_epochs $NUM_EPOCHS \ | ||
--per_gpu_train_batch_size $BATCH_SIZE \ | ||
--save_steps $SAVE_STEPS \ | ||
--seed $SEED \ | ||
--do_train \ | ||
--do_eval \ | ||
--do_predict | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if ! [ -f ./dev.txt ]; then | ||
echo "Download dev dataset...." | ||
curl -L -o ./dev.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-dev.conllu' | ||
fi | ||
|
||
if ! [ -f ./test.txt ]; then | ||
echo "Download test dataset...." | ||
curl -L -o ./test.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-test.conllu' | ||
fi | ||
|
||
if ! [ -f ./train.txt ]; then | ||
echo "Download train dataset...." | ||
curl -L -o ./train.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-train.conllu' | ||
fi | ||
|
||
export MAX_LENGTH=200 | ||
export BERT_MODEL=bert-base-uncased | ||
export OUTPUT_DIR=postagger-model | ||
export BATCH_SIZE=32 | ||
export NUM_EPOCHS=3 | ||
export SAVE_STEPS=750 | ||
export SEED=1 | ||
|
||
python3 run_ner.py \ | ||
--task_type POS \ | ||
--data_dir . \ | ||
--model_name_or_path $BERT_MODEL \ | ||
--output_dir $OUTPUT_DIR \ | ||
--max_seq_length $MAX_LENGTH \ | ||
--num_train_epochs $NUM_EPOCHS \ | ||
--per_gpu_train_batch_size $BATCH_SIZE \ | ||
--save_steps $SAVE_STEPS \ | ||
--seed $SEED \ | ||
--do_train \ | ||
--do_eval \ | ||
--do_predict | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
if ! [ -f ./dev.txt ]; then | ||
echo "Download dev dataset...." | ||
curl -L -o ./dev.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-dev.conllu' | ||
fi | ||
|
||
if ! [ -f ./test.txt ]; then | ||
echo "Download test dataset...." | ||
curl -L -o ./test.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-test.conllu' | ||
fi | ||
|
||
if ! [ -f ./train.txt ]; then | ||
echo "Download train dataset...." | ||
curl -L -o ./train.txt 'https://github.com/UniversalDependencies/UD_English-EWT/raw/master/en_ewt-ud-train.conllu' | ||
fi | ||
|
||
export MAX_LENGTH=200 | ||
export BERT_MODEL=bert-base-uncased | ||
export OUTPUT_DIR=postagger-model | ||
export BATCH_SIZE=32 | ||
export NUM_EPOCHS=3 | ||
export SAVE_STEPS=750 | ||
export SEED=1 | ||
|
||
|
||
# Add parent directory to python path to access lightning_base.py | ||
export PYTHONPATH="../":"${PYTHONPATH}" | ||
|
||
python3 run_pl_ner.py --data_dir ./ \ | ||
--task_type POS \ | ||
--model_name_or_path $BERT_MODEL \ | ||
--output_dir $OUTPUT_DIR \ | ||
--max_seq_length $MAX_LENGTH \ | ||
--num_train_epochs $NUM_EPOCHS \ | ||
--train_batch_size $BATCH_SIZE \ | ||
--seed $SEED \ | ||
--gpus 1 \ | ||
--do_train \ | ||
--do_predict |
Oops, something went wrong.