<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Hyperbolic Embedding for Finding Syntax in BERT</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Temirlan Auyespek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Thomas Mach</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zhenisbek Assylbekov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Nazarbayev University</institution>
          ,
          <addr-line>53 Kabanbay Batyr Ave, Nur-Sultan</addr-line>
          ,
          <country country="KZ">Kazakhstan</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Potsdam</institution>
          ,
          <addr-line>Karl-Liebknecht-Str. 24-25, Potsdam</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <abstract>
        <p>Recent advances in natural language processing have improved our understanding of what kind of linguistic knowledge is encoded in modern word representations. For example, methods for testing the ability to extract syntax trees from a language model architecture were developed by Hewitt and Manning (2019)-they project word vectors into Euclidean subspace in such a way that the corresponding squared Euclidean distance approximates the tree distance between words in the syntax tree. This work proposes a method for assessing whether embedding word representations in hyperbolic space can better reflect the graph structure of syntax trees. We show that the tree distance between words in a syntax tree can be approximated well by the hyperbolic distance between corresponding word vectors.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;BERT</kwd>
        <kwd>Poincaré ball</kwd>
        <kwd>Structural probe</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Recent advances in natural language processing (NLP) such as contextualized word
embeddings obtained from language models [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] gave significant advancements on natural language
understanding tasks. It is important to understand what kind of linguistic knowledge can
be encoded in these representations. There are several works that explore specific types of
linguistic knowledge, such as part-of-speech [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], morphology [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ], and syntax [
        <xref ref-type="bibr" rid="ref5 ref6 ref7">5, 6, 7</xref>
        ].
      </p>
      <p>
        On one hand the paper is inspired by [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], who proposed a method for recovering
syntactic dependencies under squared Euclidean distance and squared Poincaré distance
respectively. In this work we propose methods for extracting syntactic dependencies under Poincaré
distance without squaring. On the other hand the paper is motivated by the observation that
one cannot draw a tree in the Euclidean space with unit distance between all neighboring nodes
and without overlap, since there is not enough room for nodes, see Fig. 1 for a visualization
of the problem. Mathematically, one could argue that the number of nodes in a binary tree
expands faster than the Euclidean volume as the tree depth grows, i.e. there is always a 0 such
that
2 &gt; (2)
      </p>
      <p>for all  &gt; 0,
where  is the dimension of the Euclidean space.</p>
      <p>D</p>
      <p>B</p>
      <p>C</p>
      <sec id="sec-1-1">
        <title>Conflict!</title>
        <p>G
K
E
B
D</p>
      </sec>
      <sec id="sec-1-2">
        <title>Conflict!</title>
        <p>JH
A
G
C
F
I</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. Related work</title>
      <p>
        A method, called structural probe, was proposed for extracting syntactic knowledge from word
representations [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The probe identifies a linear transformation suited to use the squared
Euclidean distances to represent the distance between words in the parse tree.
      </p>
      <p>
        A second method, called Poincaré probe, was proposed in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and projects word representations
into a Poincaré subspace for revealing linguistic hierarchies encoded in BERT. It can be asserted
that linguistic information contained in BERT may be encoded in special metric spaces that are
not necessarily Euclidean. The hyperbolic space model, in particular the Poincaré ball, is a good
candidate due its tree-likeness [
        <xref ref-type="bibr" rid="ref8">8, 9</xref>
        ].
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Methods</title>
      <p>
        by
We start by briefly introducing hyperbolic geometry following notation from [ 10]. Hyperbolic
geometry is a geometry with a constant negative curvature. There are five isometric models
[11] and we choose the Poincaré ball as in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. The Poincaré ball with negative curvature 1 is
defined as D = {︀ x ∈ R | ‖x‖2 &lt; 1}︀ . The distance between two points u, v ∈ D is given
D(u, v) = cosh− 1
      </p>
      <p>1 + 2
︂(</p>
      <p>‖u − v‖2
(1 − ‖ u‖2)(1 − ‖ v‖2)
︂)
.</p>
      <p>For projecting points to the Poincaré ball we consider two mappings called gnomonic mapping
and hyperboloid mapping denoted by (· ) and ℎ(· ), respectively. Closed-form formulas are
(x) = √︀1 + ‖x‖2
Both of them map points from the Euclidean space to the unit ball, which is considered as
Poincaré ball. Additionally, we use the Möbius matrix-vector multiplication defined as
M ⊗ x = tanh</p>
      <p>‖x‖
︂( ‖Mx‖ tanh− 1(‖x‖)
︂)</p>
      <p>Mx
‖Mx‖
which is the hyperbolic analogue of the Euclidean linear transformation.</p>
      <p>
        Our method consists of three steps as in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], but with diferent ways of mapping into Poincaré
ball. The method is applied to word representations h1: obtained from one of the BERT’s layers
[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] for a sentence 1: consisting of words [1, . . . , ] =: 1:. The first step is applying a
linear transformation B : R ↦→ R, where  is the dimension of word representations and 
is the embedding dimension. Using this step we receive a set of vectors
The second step is applying gnomonic or hyperboloid mapping for obtaining vector reprentations
in the Poincaré ball denoted as y:
y = (x)
or
y = ℎ(x)
The final step is applying Möbius matrix-vector multiplication
ifnal vector representations denoted as z:
      </p>
      <p>M : D ↦→ D for obtaining
x = Bh
z = M ⊗ y</p>
      <p>The matrices B and M are trained in such way that the hyperbolic distance D(z, z )
resembles the graph distance  (,  ) between  and  in a syntax tree. The training
objective for one sentence is
ℓ(1:; B, M) := 12 ∑︁ | (,  ) − D(z, z )|.</p>
      <p>,
(1)
Our approach is illustrated in Fig. 2.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Experiments</title>
      <p>4.1. Setup
The main purpose of the performed experiments is to show that the usual (non-squared) Poincaré
distances can encode tree distances1.</p>
      <p>
        The training objective (1) is averaged over a set of sentences (corpus) and is minimized w.r.t.
B and M in the same way as in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. We use the Adam optimizer [12] with the learning rate
0.001. In this work we use the English Universal Dependencies dataset [13] for optimizing
(1). For evaluation of the performance we report Undirected Unlabeled Attachment Score
(UUAS) and average Spearman correlation (DSpr.). UUAS is the percentage of undirected edges
placed correctly against the syntax tree and DSpr. is the Spearman correlation between true
and predicted distances for each word in each sentence.
      </p>
      <sec id="sec-4-1">
        <title>4.2. Results</title>
        <p>
          Results for diferent embedding dimensionalities , and for diferent layers of BERT are given in
Fig. 3, where we also show the results of the Poincaré probe from [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] trained without squaring
for comparison. Table 1 shows the best result per each method.
1Results can be reproduced at https://github.com/TemirlanAuyespek/HyperbolicEmbedding
in lower dimensions. However, for dimensions higher than 16 the results become more and
more similar. Results of the exponential mapping from [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] without squaring show scores similar
to gnomonic and hyperboloid mappings, but there was a subsidence at embedding dimensions
16 and 32.
        </p>
        <p>Fig. 3 (right) shows results of UUAS for diferent BERT layers with embedding dimension
128, which we consider as a trade-of between performance and computational complexity.</p>
      </sec>
      <sec id="sec-4-2">
        <title>4.3. Visualization</title>
        <p>
          We visualize recovered dependency trees in Fig. 4 using PCA projection as [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. The results of
the two methods have a similar structure, also very similar to the original syntax tree. There
can be a certain level of distortion, but there is no good analogy of PCA in hyperbolic space
[14].
        </p>
        <p>Along with the competitive performance of our method, another important contribution of our
work is the interpretability of the obtained Poincaré ball distances because they themselves—and
not their squares—approximate syntax tree distances.</p>
        <p>(a) True syntax tree
(b) Gnomonic mapping
(c) Hyperboloid mapping
(d) True syntax tree
(e) Gnomonic mapping
(f) Hyperboloid mapping</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusion</title>
      <p>
        In this work, we introduced two methods for embedding word representations in the hyperbolic
space model, specifically the Poincaré ball. These methods were able to recover syntactic
knowledge from word representation space. The obtained results are comparable to the results
by Chen et al. [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and are sometimes better. More importantly, we showed that hyperbolic
distances can encode tree distances without any squaring. These results also confirm that the
hyperbolic spaces fit tree-structured data better than the Euclidean spaces.
      </p>
      <p>Future research will be dedicated to the investigation of other configurations of the BERT
model such as BERT Large and extracting other kinds of linguistic knowledge.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgements</title>
      <p>This work is supported by the Nazarbayev University faculty-development competitive research
grants program, grant number 240919FD3921. The authors would like to thank anonymous
reviewers for their feedback.
[9] R. Sarkar, Low distortion delaunay embedding of trees in hyperbolic plane, in: Graph</p>
      <p>Drawing, 2011.
[10] O. Ganea, G. Bécigneul, T. Hofmann, Hyperbolic neural networks, in: Proceedings
of NeurIPS, 2018, pp. 5350–5360. URL: https://proceedings.neurips.cc/paper/2018/hash/
dbab2adc8f9d078009ee3fa810bea142-Abstract.html.
[11] J. W. Cannon, W. J. Floyd, R. Kenyon, W. R. Parry, et al., Hyperbolic geometry, Flavors of
geometry 31 (1997) 59–115.
[12] D. P. Kingma, J. Ba, Adam: A method for stochastic optimization, in: Proceedings of ICLR,
2015. URL: http://arxiv.org/abs/1412.6980.
[13] N. Silveira, T. Dozat, M. de Marnefe, S. R. Bowman, M. Connor, J. Bauer, C. D. Manning,
A gold standard dependency corpus for English, in: Proceedings of LREC, 2014, pp.
2897–2904. URL: http://www.lrec-conf.org/proceedings/lrec2014/summaries/1089.html.
[14] X. Pennec, Barycentric subspace analysis on manifolds, Annals of Statistics 46 (2018)
2711–2746.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Devlin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Chang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Toutanova</surname>
          </string-name>
          ,
          <article-title>BERT: pre-training of deep bidirectional transformers for language understanding</article-title>
          ,
          <source>in: Proceedings of NAACL-HLT</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>4171</fpage>
          -
          <lpage>4186</lpage>
          . URL: https://doi.org/10.18653/v1/n19-
          <fpage>1423</fpage>
          . doi:
          <volume>10</volume>
          .18653/v1/n19-
          <fpage>1423</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Belinkov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Durrani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Dalvi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Sajjad</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. R.</given-names>
            <surname>Glass</surname>
          </string-name>
          ,
          <article-title>What do neural machine translation models learn about morphology?</article-title>
          ,
          <source>in: Proceedings of ACL</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>861</fpage>
          -
          <lpage>872</lpage>
          . URL: https: //doi.org/10.18653/v1/
          <fpage>P17</fpage>
          -1080. doi:
          <volume>10</volume>
          .18653/v1/
          <fpage>P17</fpage>
          -1080.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Peters</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Neumann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Iyyer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gardner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Clark</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Zettlemoyer</surname>
          </string-name>
          ,
          <article-title>Deep contextualized word representations</article-title>
          ,
          <source>in: Proceedings of NAACL-HLT</source>
          ,
          <year>2018</year>
          , pp.
          <fpage>2227</fpage>
          -
          <lpage>2237</lpage>
          . URL: https://doi.org/10.18653/v1/n18-
          <fpage>1202</fpage>
          . doi:
          <volume>10</volume>
          .18653/v1/n18-
          <fpage>1202</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Peters</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Neumann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Zettlemoyer</surname>
          </string-name>
          , W.-T. Yih,
          <article-title>Dissecting contextual word embeddings: Architecture and representation</article-title>
          ,
          <source>in: Proceedings of EMNLP</source>
          ,
          <year>2018</year>
          , pp.
          <fpage>1499</fpage>
          -
          <lpage>1509</lpage>
          . URL: https://doi.org/10.18653/v1/d18-
          <fpage>1179</fpage>
          . doi:
          <volume>10</volume>
          .18653/v1/d18-
          <fpage>1179</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Hewitt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. D.</given-names>
            <surname>Manning</surname>
          </string-name>
          ,
          <article-title>A structural probe for finding syntax in word representations</article-title>
          ,
          <source>in: Proceedings of NAACL-HLT</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>4129</fpage>
          -
          <lpage>4138</lpage>
          . URL: https://doi.org/10.18653/v1/ n19-
          <fpage>1419</fpage>
          . doi:
          <volume>10</volume>
          .18653/v1/n19-
          <fpage>1419</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Linzen</surname>
          </string-name>
          , E. Dupoux,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Goldberg</surname>
          </string-name>
          ,
          <article-title>Assessing the ability of lstms to learn syntax-sensitive dependencies</article-title>
          ,
          <source>Trans. Assoc. Comput. Linguistics</source>
          <volume>4</volume>
          (
          <year>2016</year>
          )
          <fpage>521</fpage>
          -
          <lpage>535</lpage>
          . URL: https://transacl. org/ojs/index.php/tacl/article/view/972.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>B.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Fu</surname>
          </string-name>
          , G. Xu,
          <string-name>
            <given-names>P.</given-names>
            <surname>Xie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Tan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Jing</surname>
          </string-name>
          ,
          <article-title>Probing BERT in hyperbolic spaces</article-title>
          ,
          <source>CoRR abs/2104</source>
          .03869 (
          <year>2021</year>
          ). URL: https://arxiv.org/abs/2104.03869. arXiv:
          <volume>2104</volume>
          .
          <fpage>03869</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M.</given-names>
            <surname>Nickel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Kiela</surname>
          </string-name>
          ,
          <article-title>Poincaré embeddings for learning hierarchical representations</article-title>
          ,
          <source>in: Proceedings of NeurIPS</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>6338</fpage>
          -
          <lpage>6347</lpage>
          . URL: https://proceedings.neurips.cc/paper/ 2017/hash/59dfa2df42d9e3d41f5b02bfc32229dd-Abstract.html.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>