# A Green AI Methodology Based on Persistent Homology for Compressing BERT
## Appendix A Homology Theory: Notation and Mathematical Background  
Firstly, based on the book [52] and the survey [53], in which a thorough explanation of homology theory can be found, some concepts are introduced, such as affine combination, affine independence, \(k-\)simplex, the face of a \(k-\)simplex, simplicial complex, chain complexes, and the boundary of a \(p-\)simplex, which are essential for building the theory of homology. Let \(v_{0},v_{1},\ldots,v_{k}\) be vectors in \(\mathbb{R}^{d}\). A point  
\[x=\sum_{i=0}^{k}\lambda_{i}v_{k}\]  
is an affine combination of the \(v_{i}\) if \(\sum_{i=0}^{k}\lambda_{i}=1\). The set of affine combinations constitutes the affine hull. **Definition A1** (Affinely independent). : _Let \(x=\sum\lambda_{i}v_{i},y=\sum\gamma_{i}v_{i}\), \(x,y\in\mathbb{R}^{d}\) affine combinations. \(x\) and \(y\) are affinely independent when \(x=y\) if and only if \(\lambda_{i}=\gamma_{i}\forall i\). In other words, in a plane of dimension \(k\) (\(k-\)plane), \(k+1\) points are affinely independent if the \(k\) vectors \(v_{i}-v_{0}\), for \(1\leq i\leq k\), are linearly independent._  
An affine combination \(x=\sum\lambda_{i}v_{i}\) is a convex combination if \(\lambda_{i}\geq 0\), for \(1\leq i\leq k\). The set of convex combinations is called the convex hull. Now, the \(k-\)simplex concept is introduced. **Definition A2** (\(k-\)simplex). : _A \(k-\)simplex, \(\sigma\), is the convex hull of \(k+1\) affinely independent points. Its dimension is \(\dim\sigma=k\)._Note that a \(0-\)simplex is a vertex, a \(1-\)simplex is an edge, a \(2-\)simplex is a triangle, and a \(3-\)simplex is a tetrahedron. A face of a \(k-\)simplex \(\sigma\) is the convex hull of a non-empty subset of \(\{v_{0},v_{1},\ldots,v_{k}\}\). If \(\tau\) is a face of \(\sigma\), then \(\tau\leq\sigma\). At this point, it is interested to focus on sets of simplices that are closed under taking faces and that have no improper intersections. **Definition A3** (Simplicial complex). : _A simplicial complex is a finite collection of simplices \(K\), such that_  
1. \(\tau\in K\,\forall t\leq\sigma,\sigma\in K\)_._
2. _If_ \(\sigma,\sigma_{0}\in K\Rightarrow\sigma\cap\sigma_{0}\) _is empty of a face of both._  
Simplicial complexes ultimately emerge as the intersection of collections of sets. While this theory is developed considering entirely general simplicial complexes, in practice, the mentioned sets will be finally considered as geometric disks. Thus, the special case of the Vietoris-Rips (VR) complex arises, where the convex sets are disks with radius \(r\). The VR complex will play a fundamental role in the methodology proposed, as it will be crucial for interpreting persistent homology and its application in PBCE towards the explainability and simplification of the BERT model. **Definition A4** (Vietoris-Rips VR complex). : _Let \((P,d)\) a finite metric space. The VR complex of \(P\) and \(r\) consisting of all subsets of diameter at most \(2r\). That is, \(\sigma\in\mathbb{R}(r)\Leftrightarrow d(p,q)\leq 2r\), \(\forall p,q\in\sigma\)._  
After introducing the most basic ideas, let us construct more elaborated concepts that will be part of the definition of the homology group or persistent homology, which are the key tools of this work. **Definition A5** (Chain complexes). : _Let \(K\) be a simplicial complex and \(p\) a dimension. A \(p-\)chain is a formal sum of \(p-\)simplices, \(c=\sum a_{i}\sigma_{i}\), where \(\sigma_{i}\) are \(p-\)simplices and the \(a_{i}\) are modulo \(2\) coefficients._  
Two \(p-\)chains can be added component-wise. In fact, \(p-\)chains with the addition operation form the abelian group of \(p-\)chains \((C_{p},+)\). A \(p-\)simplex is defined as the sum of its \((p-1)-\)dimensional faces. If \(\sigma=[v_{0},v_{1},\ldots,v_{p}]\) for the simplex defined by the listed vertices, its boundary is  
\[\partial_{p}\sigma=\sum_{j=0}^{p}[v_{0},v_{1},\ldots,\tilde{v_{j}},\ldots,v_{p }],\]  
where \(\tilde{v_{j}}\) is omitted.