-
Notifications
You must be signed in to change notification settings - Fork 9
AM parser on COGS
under construction (April 2022)
TL;DR Code documentation for the AM parser experiments in Weißenhorn et al. (2022).
This site describes how the AM parser (based on the version presented in Groschwitz et al. 2021) was adapted to the COGS dataset of Kim and Linzen (2020) targeting compositional generalization. The COGS corpus contains neo-Davidsonian-inspired logical forms as meaning representation which needed to be converted to graphs first.
- Pia Weißenhorn, Yuekun Yao, Lucia Donatelli, Alexander Koller (2022) Compositional Generalization Requires Compositional Parsers arXiv:
2202.11937 [cs.CL]
The ability of the AM parser to handle COGS meaning representation is only available on certain branches of the two main repositories:
-
am-tools: this repo is used for the pre- and postprocessing including the on-the-fly graph conversion. You need to compile an
am-tools.jarfrom the cogs branchcogs_new_decompto perform the preprocessing. -
am-parser: The neural model for the COGS AM parser is also found on a specific branch of the am-parser repo, namely the
cogs_unsupervisedbranch
Both cogs branches (am-tools, am-parser) are based on the branches for Groschwitz et al. 2021 'unsupervised parser' code.
Furthermore an am-tools.jar from the main branch is needed, as this contains the most recent version of the Astar decoder (including a bug fix important for COGS specifically: punctuation should be ignored).
Please see the main readme and sides for installing necessary dependencies for the repositories.
Main documentation for the COGS experiments is currently found in a readme here
to do: add more documentation on how to reproduce results and what files are important for this.
The MIT-licensed COGS dataset was used as-is in its commit version 6f66383 from 2nd April 2021).
| Name | Version/Commit |
|---|---|
am-tools, cogs_new_decomp branch |
commit bdbb03e on Sep 29, 2021 |
am-tools, master branch (for A* decoding) |
commit 78fac84 on Jul 8, 2021 |
am-parser, cogs_unsupervised branch |
commit b57ffad on Sep 30, 2021 |
| Java OpenJDK RE | 12.0.2 |
| Gradle | 6.7 |
| NVIDIA CUDA | 10.2 |
| Python | 3.7.3 |
| AllenNLP | 0.8.4 |
As the graphs are just an intermediary step for the AM parser, there was no need to print them to a file somewhere. The AM parser operates on AM dependency trees which are obtained by converting logical forms to graphs which in turn are directly decomposed (into tree automata summarizing different AM dependency trees before training , after training only one AM dependency tree is left) and on the post processing site predicted AM dependency trees are evaluated into fgraphs and then directly converted into logical forms again.
There is an additional caveat with respect to 'verbal primitives':
in training sets some samples contain a word in isolation plus its meaning (sees samples are called 'primitives').
Beside nouns and their meaning, some primitives contain verbs like 'crawl' or 'touch'.
Notice that they ask for arguments like agent or theme, which the grpah conversion translates into open sources beyond the root node.
As sources are learned in Groschwitz et al.'s (2021) setup, there is no unique graph for such examples, because the decomposition did not specify which source exactly should be there: does the agent edge point to a node annotated with source S0 ? or should it be S1? Or ? S2? (Similarly for theme edges).
Another caveat revolves around the necessity of alignments:
COGS logical forms contain variables such as x_1 or x_4 to represent alignment to the first or fourth input token (0-indexed).
Interestingly terms are also sorted based on these token positions (and proper noun positions whihc are not visibile in the logical form).
As COGS main evaluation metric is exact match, finding the right alignments and x_i variables is therefore crucial.
So, alhtough it is called 'graph conversion', just a graph is not a sufficient input for the conversion back to logical form. Instead graphs (more specifically nodes) have to be aligned to input tokens.
Note that a smiliar graph conversion was developed concurrently to our work by Jambór and Bahdanau (2021).
- amconll files contain supertags. These supertags are printed in PENMAN notation with node as
nodename / nodelabel. Although node names start withx_, they should not be mistaken for actual alignments to input token positions. These supertags were learnded during training to be reusable and node names are not part of the evaluation, unlike labels. For ease of presentation example graphs in published papers (Weißenhorn et al. 2022, Weißenhorn 2022) do use node names to visualize alignments, but the code does not: in the code, alignments are given by virtue of supertags being predicted for specific input tokens. - it can happen that the AM parser predicts a graph for which the conversion procedure refrains to output a logical form. So called 'ill-formed' logical forms appear if the AM parser would create a predicate such as
Ava.agent, so a proper name as part of a predicate: this is not allowed. - for reading AMCONLL files see the specific page in the AM parser wiki. If you find reading such amconll files tedious, you might want to have a look at the wiki page on visualizing AM dependency trees for error analysis
- after training:
- decoding with fixed-tree or astar decoder
- during training:
- edge model: kg, dm, kgrel (that is Kiperwasser and Goldberg, Dozat Manning, or Kiperwasser Goldberg enhanced with relative distance encodings)
- all automaton or supervised loss (supervised loss for dependency edge existence and lexical labels for supertags or have all the loss flow through tree automata?)
- embeddings (pretrained BERT or not, embedding size)
- layers and dropout, learning rate, dimensionalities
- training input:
- lex label replacement (helps for nouns, but deteriorates verb)
- prep reification or not
- use train or train100 corpus for training (need to preprocess respective files in advance of course)
- how many sources (tried 3, with 2 couldn't do distransitive verbs, 4 or more would be possible but might increase runtime)
- you can look at the average token-level edit distances (with or without exact match cases) to get a first idea of what's going on (per generalization type output provided by am-tools
ToCOGSCorpusrun with--verboseoption : will print this to stdout and all non-exact match cases to stderr): to do how to read stderr 'No exatc match found' - you can of course manually compare logical forms for individual samples of gold and prediction
- you can use
analyzers/compare_amconll.py(see am-parser wiki page for more info: 'own GUI option') to display AM dependency trees : to do example call - if predictions were generated using the projective Astar decoder (instead of the fixed-tree decoder), you can inspect the trained model's scores for supertags and dependency edges:
scores.zipis output part of unsupervised predict but can also be generated separately usingdump_scores.py, then cogs brancham-parser/analyzers/scores_prettify.py, see also the am-parser wiki page on computing scores to do: describe usage: heatmaps, output files, filtering - for fixed-tree decoder one can ask how many non-projective AM dependency trees were predicted. This script is not properly tested but might give a first hint at the degree of non-projectivity: cogs branch
am_dep_projectivity.pyThis is especially relevant for COGS since it is assumed that all gold dependency trees are projective.
- own publications regarding COGS:
- Pia Weißenhorn, Yuekun Yao, Lucia Donatelli, Alexander Koller (2022) Compositional Generalization Requires Compositional Parsers arXiv:
2202.11937 [cs.CL] - Pia Weißenhorn (2022). Investigations on what makes compositional generalization challenging. Master's thesis. Saarland University, Germany.
- Pia Weißenhorn, Yuekun Yao, Lucia Donatelli, Alexander Koller (2022) Compositional Generalization Requires Compositional Parsers arXiv:
- The COGS dataset: Kim and Linzen (2020)
- paper: Kim and Linzen (2020) COGS: A Compositional Generalization Challenge Based on Semantic Interpretation. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP) Online. Association for Computational Linguistics. pp. 9087-9105. doi: 10.18653/v1/2020.emnlp-main.731
- github: COGS dataset and their models of Kim & Linzen (2020).
- The 'unsupervised parser' (for which we added COGS as a new formalism)
- paper: Groschwitz, Fowlie and Koller (2021): Learning compositional structures for semantic graph parsing. In Proceedings of the 5th Workshop on Structured Prediction for NLP (SPNLP 2021). Online. Association for Computational Linguistics. pp. 22-36. doi: 10.18653/v1/2021.spnlp-1.3
- code:
unsupervised2020branch ofam-parser(see specifically the markdown files undergraph_dependency_parser/inside_maximization)
- branches with COGS additions:
- the AM parser wiki
- about different decoders
- fixed-tree decoder is described in Groschwitz et al. 2018, section 6.1, p.6
- projective Astar decoder is described in Lindemann et al. 2020, section 4, p.4