Commit ·
4f09c24
1
Parent(s): 11e15eb
Initial commit with adapted deliverables from Clarin: http://hdl.handle.net/20.500.12537/301
Browse filesGeneral:
- use submodules for electra model and Tokenizer package
- create missing directories
- add .python-version for 3.8 (same as for biaffine_parser)
- add .gitignore
- model file best.th in git-lfs
README.md:
- removed the Icelandic text because of redundancies
Signed-off-by: Daniel Schnell <dschnell@grammatek.com>
Files changed (20)
- .gitignoreAdded+1
- .gitmodulesAdded+3
- .python-versionAdded+1
- README.md+69-3
- TokenizerAdded+1
- combo-is-combined-v211/best.thAdded+3
- combo-is-combined-v211/config.jsonAdded+355
- combo-is-combined-v211/metrics.jsonAdded+81
- combo-is-combined-v211/vocabulary/.lockAdded
- combo-is-combined-v211/vocabulary/deprel_labels.txtAdded+37
- combo-is-combined-v211/vocabulary/feats_labels.txtAdded+50
- combo-is-combined-v211/vocabulary/lemma_characters.txtAdded+94
- combo-is-combined-v211/vocabulary/non_padded_namespaces.txtAdded+1
- combo-is-combined-v211/vocabulary/token_characters.txtAdded+108
- combo-is-combined-v211/vocabulary/upostag_labels.txtAdded+17
- combo-is-combined-v211/vocabulary/xpostag_labels.txtAdded+280
- parse_file.pyAdded+35
- requirements.txtAdded+4
- test_file.txtAdded+3
- transformer_models/electra-base-igc-isAdded+1
1venv*/123[submodule "transformer_models/electra-base-igc-is"] path = transformer_models/electra-base-igc-is url = https://huggingface.co/Icelandic-lt/electra-base-igc-is13.8123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869## A Universal Dependency parser built on top of a Transformer language modelScore on pre-tokenized test data:```Metric | Precision | Recall | F1 Score | AligndAcc-----------+-----------+-----------+-----------+-----------Tokens | 99.70 | 99.77 | 99.73 |Sentences | 100.00 | 100.00 | 100.00 |Words | 99.62 | 99.61 | 99.61 |UPOS | 96.99 | 96.97 | 96.98 | 97.36XPOS | 93.65 | 93.64 | 93.65 | 94.01UFeats | 91.31 | 91.29 | 91.30 | 91.65AllTags | 86.86 | 86.85 | 86.86 | 87.19Lemmas | 95.83 | 95.81 | 95.82 | 96.19UAS | 89.01 | 89.00 | 89.00 | 89.35LAS | 85.72 | 85.70 | 85.71 | 86.04CLAS | 81.39 | 80.91 | 81.15 | 81.34MLAS | 69.21 | 68.81 | 69.01 | 69.17BLEX | 77.44 | 76.99 | 77.22 | 77.40```Score on untokenized test data:```Metric | Precision | Recall | F1 Score | AligndAcc-----------+-----------+-----------+-----------+-----------Tokens | 99.50 | 99.66 | 99.58 |Sentences | 100.00 | 100.00 | 100.00 |Words | 99.42 | 99.50 | 99.46 |UPOS | 96.80 | 96.88 | 96.84 | 97.37XPOS | 93.48 | 93.56 | 93.52 | 94.03UFeats | 91.13 | 91.20 | 91.16 | 91.66AllTags | 86.71 | 86.78 | 86.75 | 87.22Lemmas | 95.66 | 95.74 | 95.70 | 96.22UAS | 88.76 | 88.83 | 88.80 | 89.28LAS | 85.49 | 85.55 | 85.52 | 85.99CLAS | 81.19 | 80.73 | 80.96 | 81.31MLAS | 69.06 | 68.67 | 68.87 | 69.16BLEX | 77.28 | 76.84 | 77.06 | 77.39````To use the model, you need to setup COMBO, which makes it possible to use word embeddings from a pre-trained transformer model ([electra-base-igc-is](https://huggingface.co/Icelandic-lt/electra-base-igc-is)).```bashgit submodule update --init --recursivepip install -U pip setuptools wheelpip install --index-url https://pypi.clarin-pl.eu/simple combo==1.0.5```* For Python 3.9, you might need to install cython:```bashpip install -U pip cython```* Then you can run the model as it is done in parse_file.pyFor more instructions, see here: https://gitlab.clarin-pl.eu/syntactic-tools/comboThe Tokenizer directory is a clone of [Miðeind's tokenizer](https://github.com/icelandic-lt/Tokenizer).The directory `transformer_models/` contains the pretrained model [electra-base-igc-is](https://huggingface.co/Icelandic-lt/electra-base-igc-is),which supplies the parser with contextual embeddings and attention, trained by Jón Friðrik Daðason.## Licensehttps://opensource.org/licenses/Apache-2.0
1Subproject commit 5ae4551ad3a3a99ad657bd0528dd4147f4f5f95f123version https://git-lfs.github.com/spec/v1oid sha256:98106212011d3b33fffa708d8497e0266bf233244b5209a6b2027640aeb729e9size 488929748123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355{ "dataset_reader": { "type": "conllu", "features": [ "token", "char" ], "lemma_indexers": { "char": { "type": "characters_const_padding", "character_tokenizer": { "end_tokens": [ "__END__" ], "start_tokens": [ "__START__" ] }, "min_padding_length": 32, "namespace": "lemma_characters" } }, "targets": [ "deprel", "feats", "head", "lemma", "upostag", "xpostag" ], "token_indexers": { "char": { "type": "characters_const_padding", "character_tokenizer": { "end_tokens": [ "__END__" ], "start_tokens": [ "__START__" ] }, "min_padding_length": 32 }, "feats": { "type": "feats_indexer" }, "lemma": { "type": "characters_const_padding", "character_tokenizer": { "end_tokens": [ "__END__" ], "start_tokens": [ "__START__" ] }, "min_padding_length": 32 }, "token": { "type": "pretrained_transformer_mismatched_fixed", "model_name": "transformer_models/electra-base-igc-is/", "tokenizer_kwargs": {} }, "upostag": { "type": "single_id", "feature_name": "pos_", "namespace": "upostag" }, "xpostag": { "type": "single_id", "feature_name": "tag_", "namespace": "xpostag" } }, "use_sem": false }, "model": { "type": "semantic_multitask", "dependency_relation": { "type": "combo_dependency_parsing_from_vocab", "dependency_projection_layer": { "activation": "tanh", "dropout_rate": 0.25, "in_features": 1024, "out_features": 128 }, "head_predictor": { "cycle_loss_n": 0, "dependency_projection_layer": { "activation": "tanh", "in_features": 1024, "out_features": 512 }, "head_projection_layer": { "activation": "tanh", "in_features": 1024, "out_features": 512 } }, "head_projection_layer": { "activation": "tanh", "dropout_rate": 0.25, "in_features": 1024, "out_features": 128 }, "vocab_namespace": "deprel_labels" }, "lemmatizer": { "type": "combo_lemma_predictor_from_vocab", "activations": [ "relu", "relu", "relu", "linear" ], "char_vocab_namespace": "token_characters", "dilation": [ 1, 2, 4, 1 ], "embedding_dim": 256, "filters": [ 256, 256, 256 ], "input_projection_layer": { "activation": "tanh", "dropout_rate": 0.25, "in_features": 1024, "out_features": 32 }, "kernel_size": [ 3, 3, 3, 1 ], "lemma_vocab_namespace": "lemma_characters", "padding": [ 1, 2, 4, 0 ], "stride": [ 1, 1, 1, 1 ] }, "loss_weights": { "deprel": 0.8, "feats": 0.2, "head": 0.2, "lemma": 0.05, "semrel": 0.05, "upostag": 0.05, "xpostag": 0.05 }, "morphological_feat": { "type": "combo_morpho_from_vocab", "activations": [ "tanh", "linear" ], "dropout": [ 0.25, 0 ], "hidden_dims": [ 128 ], "input_dim": 1024, "num_layers": 2, "vocab_namespace": "feats_labels" }, "regularizer": { "regexes": [ [ ".*conv1d.*", { "alpha": 1e-06, "type": "l2" } ], [ ".*forward.*", { "alpha": 1e-06, "type": "l2" } ], [ ".*backward.*", { "alpha": 1e-06, "type": "l2" } ], [ ".*char_embed.*", { "alpha": 1e-05, "type": "l2" } ] ] }, "seq_encoder": { "type": "combo_encoder", "layer_dropout_probability": 0.33, "stacked_bilstm": { "hidden_size": 512, "input_size": 164, "layer_dropout_probability": 0.33, "num_layers": 2, "recurrent_dropout_probability": 0.33 } }, "text_field_embedder": { "type": "basic", "token_embedders": { "char": { "type": "char_embeddings_from_config", "dilated_cnn_encoder": { "activations": [ "relu", "relu", "linear" ], "dilation": [ 1, 2, 4 ], "filters": [ 512, 256, 64 ], "input_dim": 64, "kernel_size": [ 3, 3, 3 ], "padding": [ 1, 2, 4 ], "stride": [ 1, 1, 1 ] }, "embedding_dim": 64 }, "token": { "type": "transformers_word_embeddings", "model_name": "transformer_models/electra-base-igc-is/", "projection_dim": 100 } } }, "upos_tagger": { "activations": [ "tanh", "linear" ], "dropout": [ 0.25, 0 ], "hidden_dims": [ 64 ], "input_dim": 1024, "num_layers": 2, "vocab_namespace": "upostag_labels" }, "xpos_tagger": { "activations": [ "tanh", "linear" ], "dropout": [ 0.25, 0 ], "hidden_dims": [ 128 ], "input_dim": 1024, "num_layers": 2, "vocab_namespace": "xpostag_labels" } }, "train_data_path": "is_combined-ud-train.conllu", "validation_data_path": "is_combined-ud-dev.conllu", "trainer": { "type": "gradient_descent_validate_n", "checkpointer": { "type": "finishing_only_checkpointer" }, "cuda_device": 0, "epoch_callbacks": [ { "type": "transfer_patience" } ], "grad_clipping": 5, "learning_rate_scheduler": { "type": "combo_scheduler" }, "num_epochs": 400, "optimizer": { "type": "adam", "betas": [ 0.9, 0.9 ], "lr": 0.002 }, "patience": 1, "validation_metric": "+EM" }, "vocabulary": { "type": "from_instances_extended", "non_padded_namespaces": [ "head_labels" ], "only_include_pretrained_words": true, "oov_token": "_", "padding_token": "__PAD__" }, "type": "default", "data_loader": { "batch_sampler": { "type": "token_count", "word_batch_size": 2500 } }, "datasets_for_vocab_creation": [ "train" ], "numpy_seed": 8787, "pytorch_seed": 8787, "random_seed": 8787}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081{ "best_epoch": 210, "peak_worker_0_memory_MB": 8525.6796875, "peak_gpu_0_memory_MB": 2498.61328125, "training_duration": "7:24:49.411776", "training_start_epoch": 0, "training_epochs": 210, "epoch": 210, "training_UPOS_ACC": 0.9787108946284663, "training_XPOS_ACC": 0.9391129495876493, "training_SEMREL_ACC": 0.0, "training_LEMMA_ACC": 0.9803898255479717, "training_FEATS_ACC": 0.919626898433172, "training_EM": 0.8210317492485046, "training_UAS": 0.94157843024532, "training_LAS": 0.9163996926968465, "training_UEM": 0.5165940054495913, "training_LEM": 0.3965122615803815, "training_EUAS": 0.0, "training_ELAS": 0.0, "training_EUEM": 0.0, "training_ELEM": 0.0, "training_partial_loss/upostag_loss": 0.1905619502067566, "training_partial_loss/xpostag_loss": 0.6266801357269287, "training_partial_loss/feats_loss": 1.8628418445587158, "training_partial_loss/lemma_loss": 0.06094415858387947, "training_partial_loss/head_loss": 0.5034704804420471, "training_partial_loss/deprel_loss": 0.3214435279369354, "training_partial_loss/cycle_loss": 0.0, "training_loss": 0.973405952516355, "training_reg_loss": 0.2107603544565408, "training_worker_0_memory_MB": 8525.6796875, "training_gpu_0_memory_MB": 2498.61328125, "training_patience": 1, "validation_UPOS_ACC": 0.9768967445412763, "validation_XPOS_ACC": 0.9429237756229287, "validation_SEMREL_ACC": 0.0, "validation_LEMMA_ACC": 0.9705140269765286, "validation_FEATS_ACC": 0.9284603739617855, "validation_EM": 0.7663625478744507, "validation_UAS": 0.8889570803158627, "validation_LAS": 0.8563888547931754, "validation_UEM": 0.3770460601446517, "validation_LEM": 0.2700799390940236, "validation_EUAS": 0.0, "validation_ELAS": 0.0, "validation_EUEM": 0.0, "validation_ELEM": 0.0, "validation_partial_loss/upostag_loss": 0.3415434658527374, "validation_partial_loss/xpostag_loss": 0.820046067237854, "validation_partial_loss/feats_loss": 1.8135327100753784, "validation_partial_loss/lemma_loss": 0.12137448042631149, "validation_partial_loss/head_loss": 1.9168964624404907, "validation_partial_loss/deprel_loss": 25.25812530517578, "validation_partial_loss/cycle_loss": 0.0, "validation_loss": 24.833287269904694, "validation_reg_loss": 0.0, "best_validation_UPOS_ACC": 0.9768967445412763, "best_validation_XPOS_ACC": 0.9429237756229287, "best_validation_SEMREL_ACC": 0.0, "best_validation_LEMMA_ACC": 0.9705140269765286, "best_validation_FEATS_ACC": 0.9284603739617855, "best_validation_EM": 0.7663625478744507, "best_validation_UAS": 0.8889570803158627, "best_validation_LAS": 0.8563888547931754, "best_validation_UEM": 0.3770460601446517, "best_validation_LEM": 0.2700799390940236, "best_validation_EUAS": 0.0, "best_validation_ELAS": 0.0, "best_validation_EUEM": 0.0, "best_validation_ELEM": 0.0, "best_validation_partial_loss/upostag_loss": 0.3415434658527374, "best_validation_partial_loss/xpostag_loss": 0.820046067237854, "best_validation_partial_loss/feats_loss": 1.8135327100753784, "best_validation_partial_loss/lemma_loss": 0.12137448042631149, "best_validation_partial_loss/head_loss": 1.9168964624404907, "best_validation_partial_loss/deprel_loss": 25.25812530517578, "best_validation_partial_loss/cycle_loss": 0.0, "best_validation_loss": 24.833287269904694, "best_validation_reg_loss": 0.0}12345678910111213141516171819202122232425262728293031323334353637_punctoblnsubjcaseadvmodccconjmarkrootobjamodnmod:posscopccompauxdetadvclaclacl:relclcompound:prtapposxcompiobjdepflat:namenummodparataxisvocativenmodexplflat:foreigndiscoursefixedcsubjcompounddislocated1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950_Number=SingDefinite=IndGender=MascCase=NomVoice=ActVerbForm=FinNumber=PlurMood=IndGender=NeutPerson=3PronType=PrsCase=AccCase=DatGender=FemTense=PastTense=PresCase=GenDefinite=DefDegree=PosPerson=1VerbForm=InfPronType=DemPronType=IndPerson=2Mood=SubVoice=MidVerbForm=PartVerbForm=SupDegree=CmpNumType=CardDegree=SupForeign=YesPronType=IntMood=ImpNumType=OrdNumType=FracNumber=NoneDefinite=NoneGender=NoneCase=NoneVoice=NoneVerbForm=NoneMood=NonePerson=NonePronType=NoneTense=NoneDegree=NoneNumType=NoneForeign=None12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394___START____END__arneigsluðtkhmvfoþájdí.,úóbypéæö"ý:?;xc102!z65-34978w„“qS—R$ÞM/GLBÓHåAENüäUPK|ÅIÐVFOTÚÖÁÍ<>1head_labels123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108___START____END__arniesutðglmkofvhþádí.,ójbyöpæúéÞ"HESýG:VAKJMOBFN?;DxLRÁÉTPIc1ÓÍ02Uz!6-Ö534987CÆÚXYW„“/<>ÐqwÝ—ZåQüä|+Å$&'1234567891011121314151617_NOUNVERBPRONPUNCTADPADVCCONJAUXDETPROPNSCONJADJPARTNUMXINTJ123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280_P.CONJADVPRO-NVBDI,N-ACN-DN-NPRO-DVBPIVBNPR-NPRO-AADJ-NBEDIN-GNS-ARPTO"NS-DPRO-GBEPINS-NNEGVBNADVRVANQ-NNPR-DADJ-ANPR-GQ-AD-ND-AMDPIADJ-DNS-GNPR-AD-DQ-DHVDIHVPIVBPSMDDSVBDSFWWADVNUM-AALSOADJ-GBEBEDSMDDINUM-NWPRO-NVBIADVSRDDIESD-GQ-GBEPSHVADJS-NHVDSBENONE-NINTJADJR-NVAGONE-ARDPIOTHER-ADODODIMDPSNPRS-DOTHER-NMDNPRS-NOTHER-DONE-DFPWPRO-AHVPSNUM-DQR-NWQADJS-ARDNQR-ARDDOPINUM-GRPXVAN-AADJR-AADJS-DQS-NSUCH-AOTHER-GNPRS-GVAN-DDONADJR-DNPRS-ADANRDPSRDDSWPRO-DOTHERS-NOTHERS-DSUCH-NWD-NSUCH-DQS-AQS-DHVNQR-DWPRO-GOTHERS-AWD-AVAG-AMDNADJR-GVAG-DFP-NCONJ-1OTHERS-GWD-DONE-GBEIADJS-GQDOPSHANNUMMAN-NSUCH-GNFP-AWQ-NDOIQR-GWPROCONJ-2QSVAN-GHVIVAG-GFP-DADJQS-GQRDODSXSUCHVBN-DLSCONJ-3WQ-AADJRCONJ-4WD-GVBN-AVAN-NBANVAG-NDAN-ANPRVB-1DAN-DWQ-DNSDAGWQ-G:HAGOTHERWPRO-1MAN-DasADJS;VBN-GWADJ-NMAGRXPRORP-2CONJ-5MDILBONES-NWADV-NVB-3MAN-ARP-3RDIFP-GWADV-DNEG-1FW-DGVB-2TPONEMANS-NNPVAN-A-4CONJ-8POR-DCONJ-6RPO-DCONJ-9VBDPNUM-1WPRO-N-1DVBNNPR-1MS-NPOR-AWRPO-NQDJ-AVAN-4DVBAGQ-ADVVPDIONES-GNPR-VADV-NPRO-N-YYYREPADJPFP-1NEG-2WADVP-10FOREIGNWADVP-5RP-6CONJ-7WDDIP-INFWADV-AADJP-NM-DADVS-NONES-AFP-N-3RANDWADV-1VBPI$ADVR-AQADVVDNRD-3ADVR-DES-APRONOTHER-WPROMAG-AWS-AANRP-1ES-1PPRAGALDJ-NFP-2N=GWDVB-4HV-11234567891011121314151617181920212223242526272829303132333435from combo.predict import COMBOfrom allennlp.data import tokenizersfrom argparse import ArgumentParser
parser = ArgumentParser()parser.add_argument('--parser')parser.add_argument('--infile')parser.add_argument('--pretokenized', action='store_true')args = parser.parse_args()
# If your data is pre-tokenized, you can add the --pretokenized flag# If you have a GPU available, you can add cuda_device=<your-device> to COMBO.from_pretrained# The parser expects input in the same format as test_file.txt, i.e. one sentence per line
if args.pretokenized: from Tokenizer.src.tokenizer import split_into_sentences nlp = COMBO.from_pretrained('combo-is-combined-v211', tokenizer=tokenizers.SpacyTokenizer(split_on_spaces=True))else: nlp = COMBO.from_pretrained(args.parser)
def read_test_file(file): with open(file, 'r', encoding='utf-8') as infile: for line in infile: if args.pretokenized: yield ' '.join(split_into_sentences(line)) else: yield line.rstrip()
test_file = read_test_file(args.infile)
for sent in test_file: sentence = nlp(sent) for index, token in enumerate(sentence.tokens, 1): print(f'{token.id}\t{token.token}\t{token.lemma}\t{token.upostag}\t{token.xpostag}\t{token.feats}\t{token.head}\t{token.deprel}\t{token.deps}\t{token.misc}') print()1234allennlp==2.10.1combo==0.1.3diaparser==1.1.2Tokenizer==3.4.2123Komið þið sæl.Þetta skjal er ætlað til að sýna hvernig þáttarinn virkar.Njótið dagsins.1Subproject commit e2921de06b441e2a3066da485d6fa31cf5c816a8.gitignoreAdded+1
.gitmodulesAdded+3
.python-versionAdded+1
README.md+69-3
TokenizerAdded+1
combo-is-combined-v211/best.thAdded+3
combo-is-combined-v211/config.jsonAdded+355
combo-is-combined-v211/metrics.jsonAdded+81
combo-is-combined-v211/vocabulary/.lockAdded
combo-is-combined-v211/vocabulary/deprel_labels.txtAdded+37
combo-is-combined-v211/vocabulary/feats_labels.txtAdded+50
combo-is-combined-v211/vocabulary/lemma_characters.txtAdded+94
combo-is-combined-v211/vocabulary/non_padded_namespaces.txtAdded+1
combo-is-combined-v211/vocabulary/token_characters.txtAdded+108
combo-is-combined-v211/vocabulary/upostag_labels.txtAdded+17
combo-is-combined-v211/vocabulary/xpostag_labels.txtAdded+280
parse_file.pyAdded+35
requirements.txtAdded+4
test_file.txtAdded+3
transformer_models/electra-base-igc-isAdded+1