#  Dynamical and Static Structure Factors in Hedgehog-Antihedgehog Order in
Icosahedral 1/1 Approximant Crystal

Shinji Watanabe∗ Department of Basic Sciences, Kyushu Institute of Technology,
Kitakyushu, Fukuoka 804-8550, Japan

###### Abstract

Recent discoveries of magnetic long-range orders in the icosahedral
quasicrystal and topological magnetic structures on the icosahedron (IC) as
the hedgehog state and the antihedgehog state have attracted great interest.
Here, we report our theoretical analysis of the dynamical as well as static
structure of the hedgehog-antihedgehog order in the 1/1 approximant crystal
(AC). By constructing the effective magnetic model for the rare-earth based
AC, on the basis of the linear spin-wave theory, the excitation energy is
shown to exhibit the reciprocal dispersion, as a consequence of preservation
of the spatial inversion symmetry by the hedgehog-antihedgehog ordering. The
static structure factor is shown to be expressed generally in the convolution
form of the lattice structure factor and the magnetic structure factor on the
IC(s) and the numerical calculation reveals the extinction rule. The dynamical
structure factor shows that the high intensities appear in the low-energy
branch along the $\Gamma$-X line and the R-$\Gamma$-M line in the reciprocal
space.

##  I Introduction

Quasicrystal (QC) has no periodicity of the lattice but possesses unique
rotation symmetry forbidden in periodic crystals. Since the discovery of the
QC Shechtman , the understanding of the lattice structure has proceeded Tsai ;
Takakura . However, the electronic state in the QC is far from complete
understanding because the Bloch theorem based on the translational invariance
can no longer be applied to the QC. Hence, the clarification of the electronic
states and the physical property in the QC is the frontier of the condensed
matter physics.

One of the interesting questions about the QC has been whether the magnetic
long-range order is realized in the three-dimensional QC. Experimentally, the
magnetic long-range order has been explored in the QC and also in the
approximant crystal (AC) whose lattice is composed of the common local atomic
structure to that in the QC with periodicity. In the rare-earth based 1/1 AC
where the 4f electrons are responsible for the magnetism, the magnetic long-
range order has been observed by the bulk measurements such as the magnetic
susceptibility and the specific heat Suzuki2021 . The antiferromagnetic (AFM)
order has been observed in the 1/1 AC Cd6R (R=Tb, Y, Pr, Nd, Sm, Gd, Tb, Dy,
Ho, Er, Tm, Yb, and Lu) Tamura2010 ; Mori  and in the 1/1 AC Au-Al-R (R=Gd and
Tb) Ishikawa2018 . The ferromagnetic (FM) order has been observed in the 1/1
AC Au-SM-R (SM=Si, Ge, and Al; R=Gd, Tb, Dy, and Ho) Hiroto2013 ; Hiroto2014 ;
Ishikawa2016  (Note that Au-SM-R is the composition tunable compound which
exhibits the FM order and AFM order depending on the composition ratio of Au
and SM, e.g., AuxAl86-xGd [10].). As for the QC, the spin-glass behavior has
been observed in the QC Cd-R (R=Gd, Tb, Dy, Ho, Er, and Tm) Goldman .
Recently, the FM orders have been discovered in the QC Au65Ga20R15 (R=Gd and
Tb) Tamura2021  and in AuxGa85-xDy15 $(x=62$-$68)$ Takeuchi2023 , which have
brought about the breakthrough.

Among these ACs and QCs, the neutron measurements have been performed recently
in some Tb-based ACs and Ho-based AC, which have revealed the non-collinear
and non-coplanar alignments of the 4f magnetic moments of the ferrimagnet in
the 1/1 ACs Au70Si17Tb13 Hiroto  and Au-Si-R (R=Tb, Ho) Gebresenbut  as well
as the antiferromagnet in the 1/1 AC Au72Al14Tb14 Sato2019 .

These ACs and the QCs are composed of the concentric shell structures of
atomic polyhedrons, which is referred to as the Tsai-type cluster Tsai ;
Takakura . Inside the Tsai-type cluster, the rare-earth atoms are located at
the 12 vertices of the icosahedron (IC) [see Fig. 1(a)]. To understand the
magnetic property of the rare-earth based icosahderal QCs and ACs, the
clarification of the crystalline electric field (CEF) at the rare-earth site
is necessary.

Recently, theoretical formulation of the CEF at the rare-earth site in the QC
and AC has been developed on the basis of the point charge model WK2021 . By
applying this formulation to the QC Au-Al-Yb WK2021  and Au-SM-Tb WSR ; WPNAS
, the CEF was analyzed theoretically. Then, it was shown that the CEF ground
state possesses the uniaxial anisotropy at each rare-earth site, giving rise
to the unique magnetic structures on the IC WSR ; WPNAS . Interestingly, the
magnetic structures which have finite topological charge $n$ defined on the IC
such as the hedgehog state displayed in Fig. 1(a) have been shown to appear.
The topological charge has the physical meaning of the number of covering the
whole sphere by the magnetic moments on the IC. The hedgehog state, where all
12 magnetic moments are directed outward from the IC shown in Fig. 1(a), has
$n=+1$ WSR . The antihedgehog state, where all 12 magnetic moments are
directed inward from the IC as displayed in Fig. 1(b), has $n=-1$. The
hedgehog state is regarded as the source of the emergent field while the
antihedgehog state is regarded as the sink of the emergent field Kanazawa ;
Tokura2021 .

Then, the effective model for the magnetism in the 1/1 AC and QC, where the
magnetic easy axis at each Tb site arising from the CEF is taken into account,
was constructed WSR ; WPNAS . By numerical calculations in the effective model
applied to the Cd5.7Yb-type QC Takakura , it has been shown that the uniform
hedgehog state is stabilized in the ground-state phase diagram WSR . This is
the theoretical discovery of the topological magnetic state in the QC, which
has attracted great interest. Moreover, the recent analysis of the dynamical
structure factor in the QC has revealed that the non-reciprocal excitation in
the uniform hedgehog order emerges in the vast extent of the wave vector
${\bm{q}}$-energy $\omega$ plane, i.e., $S({\bm{q}},\omega)\neq
S(-{\bm{q}},\omega)$ WHH2022 .

Figure 1:  (a) The hedgehog state on the IC. The number labels the Tb sites at
the 12 vertices of the IC. (b) The antihedgehog state on the IC. (c) The
hedgehog-antihedgehog order in the 1/1 AC. The frame box is the bcc unit cell.
(d) The nearest-neighbor (N.N.) interactions $J_{1}$ (blue line) and next-
nearest-neighbor (N.N.N.) interactions $J_{2}$ (green dashed line) for the
intra IC and the inter IC are illustrated.

To get insight into the emergence mechanism of the nonreciprocal excitation,
the dynamical structure factor in the 1/1 AC has been analyzed recently by
assuming the uniform hedgehog order W2023 . Then, the non-reciprocal energy
dispersion of magnon has been shown to appear as a consequence of the
inversion symmetry breaking by the uniform hedgehog ordering W2023 .

In the ground-state phase diagram of the effective model applied to the 1/1
AC, it was shown that the hedgehog state forms the AFM order WSR ; WPNAS .
Namely, the hedgehog state is formed on the IC located at the center of the
unit cell of the body-centered cubic (bcc) lattice while the antihedgehog
state is formed on the IC located at the corner of the bcc unit cell as shown
in Fig. 1(c) WSR ; WPNAS . In this study, we theoretically analyze the
dynamical as well as static structure factor in the AFM hedgehog order in the
1/1 AC as the true ground state. It is shown that the reciprocal excitation
emerges, which is in sharp contrast to the case of the uniform hedgehog order
in the 1/1 AC. This is understood as the alternative distribution of the
hedgehog state and antihedgehog state preserves the inversion symmetry in the
1/1 AC.

Recently, the dynamical structure factors for the topological magnetic
textures such as the Skyrmion and the hedgehog in periodic crystals have been
studied Kato2021 ; Eto2022 , which have attracted interest. As for the QC, the
lattice dynamics was studied in the Zn-Mg-Sc icosahedral QC and the 1/1 AC by
inelastic X-ray- and neutron-scattering experiments Boissieu . Theoretically,
the dynamical spin structure factors were studied in the low-dimensional
systems such as the Fibonacci chain Ashraff1989  and the two dimensional QCs
Ashraff1990 ; Wessel2005 . Hence, the present study in the three dimensional
icosahedral AC considering the magnetic anisotropy arising from the CEF is
expected not only to contribute to the understanding the dynamics of the
topological magnetic texture but also to get insight into the unique magnetic
structure in the icosahedral QC.

The organization of this paper is as follows: In section II, we introduce the
effective model for magnetism in the rare-earth based 1/1 AC. In section III,
we analyze the static structure factor of magnetism in the hedgehog-
antihedgehog order in the 1/1 AC. In section IV, we explain the linear spin-
wave theory applied to the 1/1 AC and show the results of the excitation
energy and the dynamical structure factor in the hedgehog-antihedgehog order
in the 1/1 AC. In section V, we summarize the paper and discuss the future
issues.

##  II Effective model for magnetism

By taking into account the effect of the magnetic anisotropy arising from the
CEF, the effective minimal model for magnetism in the rare-earth based QC and
AC has been constructed WSR ; WPNAS . In this study, we consider the effective
minimal model

$\displaystyle H=\sum_{\langle
i,j\rangle}J_{ij}{\bm{S}}_{i}\cdot{\bm{S}}_{j}-D\sum_{i}({\bm{S}}_{i}\cdot\hat{\bm{e}}^{i}_{3})^{2}$
(1)

in the 1/1 AC. As the atomic coordinates, we employ the lattice structure of
the 1/1 AC identified by the X-ray measurement in Au70Si17Tb13 Hiroto . The
frame box shown in Fig. 1(c) represents the unit cell of the bcc lattice with
the lattice constant $a=14.726~{}{\rm\AA}$ where the two ICs are located at
the center and the corner.

In Eq. (1), ${\bm{S}}_{i}$ represents the magnetic moment of the total angular
momentum $J=6$ at the $i$th Tb site with $S_{i}=6$, which is referred to as
“spin” hereafter. The second term in Eq. (1) expresses the effect of the
uniaxial anisotropy due to the CEF, where $\hat{\bm{e}}^{i}_{3}$ is the unit
vector directed to the magnetic easy axis at each Tb site (see section IV and
also Fig. 3 below).

In Eq. (1), $J_{ij}$ is set to be the nearest neighbor (N.N.) interaction
$J_{1}$ and the next N.N. (N.N.N.) interaction $J_{2}$ for the intra IC and
also for the inter IC. In ref. WPNAS , the ground-state phase diagram of the
model (1) for the large-$D$ limit was discussed, where the stability of the
ground state in the 1/1 AC was analyzed by comparing the energy of the uniform
distribution of the magnetic ground state on the IC and the staggered
distribution. Recently, the numerical calculation for the ground state of the
model for the large-$D$ limit in the 1/1 AC has been performed without
assuming the ground state on the IC W2023b . Namely, in the large-$D$ limit of
the model (1), the ground state phase diagram was determined by numerical
calculations, where the AFM hedgehog order, i.e., the hedgehog-antihedgehog
order shown in Fig. 1(c) is realized for $J_{2}/J_{1}<0.284$ with the FM
interaction $J_{1}<0$ WPNAS ; W2023b . The strong N.N. interaction $J_{1}$
stabilizes the hedgehog state and antihedgehog state at the center IC and
corner IC in the bcc unit cell in Fig. 1(c) not only for the intra IC but also
for the inter IC. In this paper, we take $J_{1}$ as the energy unit, i.e., set
$J_{1}=-1.0$ and mainly show the results for $J_{2}=-0.1$ as the typical
parameter.

We note that the effective model which corresponds to the large-$D$ limit of
the model (1) succeeded in explaining the magnetic structures of the FM order
of the ferrimagnetism on the IC observed in the 1/1 AC Au70Si17Tb13 Hiroto
and the AFM order of the whirling-antiwhirling states on the ICs observed in
the 1/1 AC Au72Al14Tb14 Sato2019 ; WPNAS . The model (1) is expected to be
relevant to not only the Tb-based AC but also the broad range of the rare-
earth based-ACs.

The interaction $J_{ij}$ in the first term of Eq. (1) set in this study is
explicitly noted as follows: $J_{1}$ is set for 5 bonds for each Tb site with
the bond length $0.374a$ (1 bond) and $0.378a$ (4 bonds) and $J_{2}$ is set
for 5 bonds for each Tb site with the bond length $0.610a$ (4 bonds) and
$0.612a$ (1 bond) for the intra IC [see Fig. 1(d)]. For the inter IC, $J_{1}$
is set for 5 bonds for each Tb site with the bond length $0.368a$ (4 bonds)
and $0.388a$ (1 bond) and $J_{2}$ is set for 7 bonds with the bond length
$0.528a$ (2 bonds), $0.530a$ (4 bonds), and $0.539a$ (1 bond) [see Fig. 1(d)].

In this paper, we analyze the property of the dynamics of the hedgehog-
antihedgehog ordered state shown in Fig. 1(c) by applying the liner spin-wave
theory to the model (1) for large $D$. Namely, the excitation from the ground
state of the classical limit of the model (1) is analyzed. Hence,
$\hat{\bm{e}}_{3}^{i}$ in the second term of Eq. (1) is set as
$(\pm\frac{1}{\sqrt{\tau+2}},\pm\frac{\tau}{\sqrt{\tau+2}},0)$ for the
$i=1,3,11$, and 12th site on the IC in Fig. 1(a),
$(\pm\frac{\tau}{\sqrt{\tau+2}},0,\pm\frac{1}{\sqrt{\tau+2}})$ for the
$i=5,6,8$, and 9th site, and
$(0,\pm\frac{1}{\sqrt{\tau+2}},\pm\frac{\tau}{\sqrt{\tau+2}})$ for $i=2,4,7$,
and 10th site, respectively, where $\tau$ is the golden mean
$\tau=(1+\sqrt{5})/2$.

##  III Static structure factor of magnetism

First, let us analyze the static structure factor

$\displaystyle
F_{s}({\bm{q}})=\left\langle\left|\frac{1}{N}\sum_{i}{\bm{S}}_{i}e^{i{\bm{q}}\cdot{\bm{r}}_{i}}\right|^{2}\right\rangle,$
(2)

for the ground state of the hedgehog-antihedgehog order in the 1/1 AC. Here,
$N$ is the total number of the Tb sites and ${\bm{q}}$ is the wave vector.
Since the position vector of the $i$th Tb site ${\bm{r}}_{i}$ is expressed as
${\bm{r}}_{i}={\bm{R}}_{j}+{\bm{r}}_{0m}$ where ${\bm{R}}_{j}$ is the position
vector of the center of the $j$th unit cell [see Fig. 1(c)] and
${\bm{r}}_{0m}$ is the position vector of the $m$th Tb site inside the unit
cell $(m=1,2,\cdots,24)$, Eq. (2) is expressed as the convolution form

$\displaystyle F_{s}({\bm{q}})=F_{L}({\bm{q}})S_{2{\rm IC}}({\bm{q}}).$ (3)

Here, $F_{L}({\bm{q}})$ is the structure factor of the lattice and $S_{2{\rm
IC}}({\bm{q}})$ is the magnetic structure factor of the 2 ICs inside the unit
cell, which are defined as

$\displaystyle F_{L}({\bm{q}})$ $\displaystyle=$
$\displaystyle\frac{1}{N_{L}^{2}}\sum_{j=1}^{N_{L}}\sum_{j^{\prime}=1}^{N_{L}}e^{i{\bm{q}}\cdot({\bm{R}}_{j}-{\bm{R}}_{j^{\prime}})},$
(4) $\displaystyle S_{2{\rm IC}}({\bm{q}})$ $\displaystyle=$
$\displaystyle\frac{1}{24^{2}}\sum_{m=1}^{24}\sum_{m^{\prime}=1}^{24}\langle{\bm{S}}_{m}\cdot{\bm{S}}_{m^{\prime}}\rangle
e^{i{\bm{q}}\cdot({\bm{r}}_{0m}-{\bm{r}}_{0m^{\prime}})},$ (5)

respectively. Here, $N_{L}=N_{1}^{3}$ is the number of the unit cell and
$N=24N_{L}$ holds.

The position vector ${\bm{R}}_{j}$ is expressed as

$\displaystyle{\bm{R}}_{j}=n_{1}{\bm{a}}_{1}+n_{2}{\bm{a}}_{2}+n_{3}{\bm{a}}_{3},$
(6)

where ${\bm{a}}_{i}$ is the basic translation vector of the lattice defined by
${\bm{a}}_{1}=a(1,0,0)$, ${\bm{a}}_{2}=a(0,1,0)$, and ${\bm{a}}_{3}=a(0,0,1)$
with integer $n_{i}$ $(i=1,2,3)$. The wave vector ${\bm{q}}$ is expressed as

$\displaystyle{\bm{q}}=h{\bm{b}}_{1}+k{\bm{b}}_{2}+l{\bm{b}}_{3},$ (7)

where ${\bm{b}}_{i}$ is the basic translation vector of the reciprocal lattice
defined by ${\bm{b}}_{1}=\frac{2\pi}{a}(1,0,0)$,
${\bm{b}}_{2}=\frac{2\pi}{a}(0,1,0)$, and
${\bm{b}}_{3}=\frac{2\pi}{a}(0,0,1)$. Under the periodic boundary condition
along the $N_{1}{\bm{a}}_{i}$ $(i=1,2,3)$ directions, $h$, $k$, and $l$ are
given by $h=\frac{m_{1}}{N_{1}}$, $k=\frac{m_{2}}{N_{1}}$, and
$l=\frac{m_{3}}{N_{1}}$, respectively with integer $m_{i}$ $(i=1,2,3)$.

By substituting Eqs. (6) and (7) into Eq. (4), $F_{L}({\bm{q}})$ is calculated
as

$\displaystyle F_{L}({\bm{q}})=\frac{1}{N_{L}^{2}}\frac{\sin^{2}(\pi
hN_{1})}{\sin^{2}(\pi h)}\frac{\sin^{2}(\pi kN_{1})}{\sin^{2}(\pi
k)}\frac{\sin^{2}(\pi lN_{1})}{\sin^{2}(\pi l)}.$ (8)

For integer $h$, $k$, and $l$, Eq. (7) becomes the reciprocal lattice vector
${\bm{q}}={\bm{Q}}_{hkl}\equiv h{\bm{b}}_{1}+k{\bm{b}}_{2}+l{\bm{b}}_{3}$.
Then, Eq. (8) leads to $F_{L}({\bm{Q}}_{hkl})=1$. As $h$, $k$, and $l$ deviate
from the integer values, $F_{L}({\bm{q}})$ decays rapidly in the finite-size
system. In the bulk limit, namely for $N_{1}\to\infty$, we obtain

$\displaystyle F_{L}(\bm{q})=\delta_{{\bm{q}},{\bm{Q}}_{hkl}}.$ (9)

This implies that from the convolution form of Eq. (3), the static structure
factor $F_{s}({\bm{q}})$ can have the non-zero value for integer $h$, $k$, and
$l$ where $F_{L}({\bm{q}})$ becomes non zero.

Next, let us analyze the magnetic structure factor of the 2 ICs inside the
unit cell [see Fig. 1(c)] $S_{2{\rm IC}}({\bm{q}})$ defined in Eq. (5). We
have calculated $S_{2{\rm IC}}({\bm{q}})$ in Eq. (5) in the system for
$N_{L}=N_{1}^{3}$ with $N_{1}=256$ numerically. By searching the maximum of
$S_{2{\rm IC}}({\bm{q}})$ for
${\bm{q}}=h{\bm{b}}_{1}+k{\bm{b}}_{2}+l{\bm{b}}_{3}$ with integers
$h,k,l\in[-10,10]$ numerically, we find that the maximum value $0.2158$
appears at the 12 ${\bm{q}}$ points with $(h,k,l)=(\pm 10,0,\pm 9)$, $(0,\pm
9,\pm 10)$, and $(\pm 9,\pm 10,0)$. We plot $S_{2{\rm IC}}({\bm{q}})$ for
${\bm{q}}=\frac{2\pi}{a}(h,k,0)$ in the $h$-$k$ plane in Fig. 2(a). We have
confirmed that $S_{2{\rm IC}}({\bm{q}})=0$ for
${\bm{q}}=\frac{2\pi}{a}(h,k,l)$ in case that all $h$, $k$, and $l$ are even
integers or one of $h$, $k$, and $l$ is even integer. We have also calculated
$S_{2{\rm IC}}({\bm{q}})$ for ${\bm{q}}=\frac{2\pi}{a}(0,k,l)$ and for
${\bm{q}}=\frac{2\pi}{a}(h,0,l)$. The results are the same as Fig. 2(a) with
$h$ and $k$ being replaced with $k$ and $l$ respectively and with $h$ and $k$
being replaced with $l$ and $h$ respectively. The systematic absence of
reflection $S_{2{\rm IC}}({\bm{q}})$ occurs for
${\bm{q}}=\frac{2\pi}{a}(h,k,l)$ for all or one of even integer among $h$,
$k$, and $l$.

Figure 2:  (a) The intensity plot of the magnetic structure factor for the 2
ICs $S_{2{\rm IC}}({\bm{q}})$ for ${\bm{q}}=\frac{2\pi}{a}(h,k,0)$ in the
$h$-$k$ plane. (b) The intensity plot of the magnetic structure factor
$F_{s}({\bm{q}})$ for ${\bm{q}}=\frac{2\pi}{a}(h,k,0)$ in the $h$-$k$ plane.
The color scale is common to that in (a).

From Eq. (3) and Eq. (9), it turns out that $F_{s}({\bm{q}})$ in the bulk
limit is equivalent to $S_{2{\rm IC}}({\bm{q}})$ for
${\bm{q}}=h{\bm{b}}_{1}+k{\bm{b}}_{2}+l{\bm{b}}_{3}$ with integers $h$, $k$,
and $l$. Hence, the maximum of $F_{s}({\bm{q}})$ appears at $(h,k,l)=(\pm
10,0,\pm 9)$, $(0,\pm 9,\pm 10)$, and $(\pm 9,\pm 10,0)$ for $h$, $k$,
$l\in[-10,10]$. We plot the static magnetic structure factor $F_{s}({\bm{q}})$
for ${\bm{q}}=\frac{2\pi}{a}(h,k,0)$ in the $h$-$k$ plane in Fig. 2(b). As
noted above, $F_{s}({\bm{q}})$ for ${\bm{q}}=\frac{2\pi}{a}(0,k,l)$ and
${\bm{q}}=\frac{2\pi}{a}(h,0,l)$ are obtained by replacing $h$ and $k$ in Fig.
2(b) with $k$ and $l$ respectively and with $l$ and $h$ respectively. The
systematic absence of reflection $F_{s}({\bm{q}})=0$ occurs for
${\bm{q}}=\frac{2\pi}{a}(h,k,l)$ for the even integers $h$, $k$, and $l$ and
also for the case that the two of $h$, $k$, and $l$ are odd integers.

##  IV Linear spin-wave theory

Figure 3:  Local orthogonal coordinate at the $i$th site spanned by unit
vectors $\hat{\bm{e}}_{i}$ $(i=1,2,3)$. The unit vector $\hat{\bm{e}}^{i}_{3}$
is set along the magnetic-moment direction at each site.

To analyze the dynamical structure factor as well as the excitation energy in
the hedgehog-antihedgehog order in the 1/1 AC, we employ the linear spin-wave
theory. Since the hedgehog state and antihedgehog state are the non-collinear
as well as non-coplanar magnetic state, it is convenient to introduce the
orthogonal coordinate at each Tb site. As shown in Fig. 3, the local
coordinate at the $i$th Tb site is spanned by the unit vectors
$\hat{\bm{e}}^{i}_{\beta}$ $(\beta=1,2$, and $3)$, where
$\hat{\bm{e}}^{i}_{3}$ points to the magnetic-moment direction. The unit
vector $\hat{\bm{e}}^{i}_{\beta}$ and the unit vector $\hat{\bm{r}}_{\alpha}$
in the global coordinate
$(\hat{\bm{r}}_{1}\equiv\hat{\bm{x}},\hat{\bm{r}}_{2}\equiv\hat{\bm{y}}$, and
$\hat{\bm{r}}_{3}\equiv\hat{\bm{z}})$ are related as

$\displaystyle\hat{\bm{r}}_{\alpha}=R_{\alpha\beta}^{i}\hat{\bm{e}}_{\beta}^{i},$
(10)

where the direction of $\hat{\bm{e}}^{i}_{3}$ is denoted by the polar angles
$(\theta_{i},\phi_{i})$ and $R^{i}$ is the rotation matrix defined by
Haraldsen ,

$\displaystyle
R^{i}=\begin{bmatrix}\cos\theta_{i}\cos\phi_{i}&-\sin\phi_{i}&\sin\theta_{i}\cos\phi_{i}\\\
\cos\theta_{i}\sin\phi_{i}&\cos\phi_{i}&\sin\theta_{i}\sin\phi_{i}\\\
-\sin\theta_{i}&0&\cos\theta_{i}\end{bmatrix}.$ (11)

Then, the “spin” interaction between the $i$th and $j$th sites in the first
term of Eq. (1) is written as

$\displaystyle\sum_{\langle
i,j\rangle}J_{i,j}({\bm{S}}_{i}\cdot{\bm{e}}_{\alpha}^{i})({\bm{S}}_{j}\cdot{\bm{e}}_{\beta}^{j})\sum_{\gamma}R_{\alpha,\gamma}^{i}R_{\gamma,\beta}^{j}.$
(12)

After substituting the relations
${\bm{S}}_{i}\cdot\hat{\bm{e}}_{1}^{i}=(S_{i}^{+}+S_{i}^{-})/2$ and
${\bm{S}}_{i}\cdot\hat{\bm{e}}_{2}^{i}=(S_{i}^{+}-S_{i}^{-})/(2i)$ into Eq.
(12), where $S_{i}^{+}$ is the raising “spin” operator and $S_{i}^{-}$ is the
lowering “spin” operator, the Holstein-Primakoff transformation HP  is applied
to $H$. In this way, the “spin” operators in Eq. (1) are transformed into the
boson operators as $S_{i}^{+}=\sqrt{2S-n_{i}}a_{i}$,
$S_{i}^{-}=a_{i}^{\dagger}\sqrt{2S-n_{i}}$ and
${\bm{S}}_{i}\cdot\hat{\bm{e}}_{3}^{i}=S-n_{i}$ with $n_{i}\equiv
a_{i}^{\dagger}a_{i}$ where $a^{\dagger}_{i}$ $(a_{i})$ is the creation
(annihilation) operator of the boson at the $i$th site. We keep the quadratic
terms with respect to $a_{i}^{\dagger}$ and $a_{i}$, which are speculated to
be valid at least for the ground state. Since the hedgehog state and
antihedgehog state have non-collinear “spin” alignments, the anomalous terms
such as $a_{i}a_{j}$ and $a^{\dagger}_{i}a^{\dagger}_{j}$ emerge besides the
normal terms $a^{\dagger}_{i}a_{j}$ and $a_{i}a^{\dagger}_{j}$.

As noted below Eq. (2), the position vector of the $i$th site is expressed as
${\bm{r}}_{i}={\bm{R}}_{j}+{\bm{r}}_{0m}$ where ${\bm{R}}_{j}$ denotes the
position of the center of the $j$th unit cell and ${\bm{r}}_{0m}$
$(m=1,2,\cdots,24)$ denotes the position of the $m$th Tb site inside the unit
cell. Hence, by carrying out the Fourie transformations
$a_{i}=a_{j,m}=\frac{1}{\sqrt{N_{L}}}\sum_{\bm{q}}e^{i{\bm{q}}\cdot({\bm{R}}_{j}+{\bm{r}}_{0m})}a_{{\bm{q}},m}$
and
$a^{\dagger}_{i}=a^{\dagger}_{j,m}=\frac{1}{\sqrt{N_{L}}}\sum_{\bm{q}}e^{-i{\bm{q}}\cdot({\bm{R}}_{j}+{\bm{r}}_{0m})}a^{\dagger}_{{\bm{q}},m}$
with ${\bm{q}}$ being the wave vector, the spin-wave Hamiltonian is expressed
as the boson operators $a^{\dagger}_{{\bm{q}},m}$ and $a_{{\bm{q}},m}$. Then,
by executing the para-unitary transformation Colpa  i.e., the Bogoliubov
transformation, the spin-wave Hamiltonian is diagonalized as

$\displaystyle
H=\sum_{\bm{q}}\sum_{m^{\prime}=1}^{24}\omega_{m^{\prime}}({\bm{q}})b^{\dagger}_{{\bm{q}},m^{\prime}}b_{{\bm{q}},m^{\prime}},$
(13)

where $\omega_{m^{\prime}}({\bm{q}})(>0)$ is the energy of the $m^{\prime}$th
spin wave. Here, $b^{\dagger}_{{\bm{q}},m^{\prime}}$
$(b_{{\bm{q}},m^{\prime}})$ is the creation (annihilation) operator of the
boson which is composed of the linear combination of
$a^{\dagger}_{{\bm{q}},m}$ and $a_{{\bm{q}},m}$.

###  IV.1 Energy dispersion of excitation from hedgehog-anti-hedgehog order

We analyze the energy dispersion of the excitation
$\omega_{m^{\prime}}({\bm{q}})$ in the hedgehog-antihedgehog order in the 1/1
AC. We have performed the numerical calculations for $J_{1}=-1.0$ and
$J_{2}=-0.1$ in the systems for $N_{L}=N_{1}^{3}$ with $N_{1}=8$, 16, 32, 64,
and 128. The results of the excitation energy $\omega_{m^{\prime}}({\bm{q}})$
for $N_{1}=64$ and $128$ are seen as the same and we show the result in the
system with $N_{1}=128$ for for $D=50$ in Fig. 4. Here ${\bm{q}}$ is plotted
along the symmetry line (orange line) in the Brillouin zone illustrated as the
frame box with the side length $\frac{2\pi}{a}$ in the inset. The coordinate
of each symmetry point in the reciprocal space is as follows: $\Gamma$:
$(0,0,0)$, X: $\frac{2\pi}{a}(\frac{1}{2},0,0)$, M:
$\frac{2\pi}{a}(\frac{1}{2},\frac{1}{2},0)$, and R:
$\frac{2\pi}{a}(\frac{1}{2},\frac{1}{2},\frac{1}{2})$. Since there exist 24 Tb
sites in the unit cell [see Fig. 1(c)], the 24 energy bands for the excitation
appear in Fig. 4. Because of the uniaxial anisotropy $D$ arising from the CEF,
the lowest excitation energy appears at the finite energy. It is noted that
the energy gap opens for $D\geq 1.7836$ which was obtained by the linear-spin-
wave calculation assuming the hedgehog-antihedgehog order as the ground state.
It is cofirmed that the overall features of the energy dispersions of the
magnetic excitations $\omega({\bm{q}})$ shown in Fig. 4 are the same as long
as $D\mathop{\vtop{\halign{#\cr$\hfil\displaystyle{>}\hfil$\crcr\kern
1.0pt\nointerlineskip\cr$\,\sim$ \crcr\kern 1.0pt\cr}}}\limits 5$.

Figure 4:  The energy dispersion of the excitation in the hedgehog-
antihedgehog order in the 1/1 AC for $D=50$ at $J_{1}=-1.0$ and $J_{2}=-0.1$.
The inset illustrates the Brillouin zone of the cubic unit cell with the side
length $\frac{2\pi}{a}$.

In Fig. 4, we also plot $\omega_{m^{\prime}}(-{\bm{q}})$ as the blue dashed
line for ${\bm{q}}$ along the symmetry line illustrated in the inset, where
$-{\bm{q}}$ follows the blue line in the inset. We see that all the blue
dashed lines coincide with the orange solid lines, which indicates that the
reciprocal energy dispersion
$\omega_{m^{\prime}}({\bm{q}})=\omega_{m^{\prime}}(-{\bm{q}})$ is realized.
This is in sharp contrast to the nonreciprocal energy dispersion
$\omega_{m^{\prime}}({\bm{q}})\neq\omega_{m^{\prime}}(-{\bm{q}})$ shown in the
uniform hedgehog order in the QC WHH2022  and 1/1 AC W2023 . This can be
intuitively understood in terms of the symmetry operation as follows.

Let us consider the global coordinate in Fig. 1(c) whose origin is set to be
the center of the unit cell. When the magnetic moment located at the position
${\bm{r}}$ in Fig. 1(c) is spatially inverted as $-{\bm{r}}$ with the moment
direction being kept, the hedgehog state on the central IC is transformed to
the antihedgehog state and the antihedgehog state on the corner IC is
transformed to the hedgehog state, as shown in Fig. 5. Since the magnetic
structure shown in Fig. 5 is regarded to be equivalent to that shown in Fig.
1(c) as the global structure of the whole crystal, the spatial inversion
symmetry is not broken by the hedgehog-antihedgehog ordering. Hence, the
reciprocal energy dispersion is understood to appear in Fig. 4.

Figure 5:  In the 1/1 AC, the antihedgehog state on the center IC and the
hedgehog state on the corner IC in the bcc unit cell illustrated by the frame
box.

On the contrary, in the case of the uniform hedgehog order in the 1/1 AC, when
the magnetic moment located at the position ${\bm{r}}$ is spatially inverted
as $-{\bm{r}}$ with the moment direction being kept, both the hedgehog states
on the central IC and the corner IC are transformed to the antihedgehog
states. Since the uniform hedgehog state and the uniform antihedgehog state
are different magnetic states each other, this implies that the spatially
inversion symmetry is broken by the uniform hedgehog ordering. The same is
applied to the uniform hedgehog order in the QC discussed in Ref. WHH2022 .
Hence, nonreciprocal energy dispersions emerge, i.e.,
$\omega_{m^{\prime}}({\bm{q}})\neq\omega_{m^{\prime}}(-{\bm{q}})$, in these
cases.

From these analyzes, it turns out that the pair formation of the hedgehog
state and the antihedgehog state in the 1/1 AC [see Fig. 1(c) and Fig. 5]
preserves the inversion symmetry.

###  IV.2 Dynamical structure factor of magnetism

On the basis of the linear spin-wave theory, we analyze the dynamics of the
magnetic excitation in the hedgehog-antihedgehog order in the 1/1 AC. The
magnetic dynamical structure factor is defined by

$\displaystyle S_{\alpha\beta}({\bm{q}},\omega)=-\frac{1}{\pi}{\rm
Im}\langle{\rm
GS}|S_{{\bm{q}}\alpha}\frac{1}{\omega+E_{0}-H+i\eta}S_{-{\bm{q}}\beta}|{\rm
GS}\rangle,$ (14)

where $|{\rm GS}\rangle$ is the ground state with the energy $E_{0}$ and
$S_{{\bm{q}}\alpha}$ is the Fourier transformation of the “spin” operator
defined by
$S_{{\bm{q}}\alpha}=\frac{1}{\sqrt{N}}\sum_{i=1}^{N}e^{-i{\bm{q}}\cdot{\bm{r}}_{i}}S_{i\alpha}$.
In this study, we set $\eta=10^{-3}$. Experimentally, the magnetic dynamical
structure factor can be observed by the neutron measurement. The intensity of
inelastic neutron scattering is expressed by the dynamical structure factor

$\displaystyle
S_{\perp}({\bm{q}},\omega)=\sum_{\alpha,\beta=x,y,z}(\delta_{\alpha\beta}-\hat{q}_{\alpha}\hat{q}_{\beta})S_{\alpha\beta}({\bm{q}},\omega),$
(15)

where ${\bm{q}}$ is the incident wave vector and $\hat{q}_{\alpha}$ is defined
as $\hat{q}_{\alpha}\equiv q_{\alpha}/|{\bm{q}}|$ Squires . We have performed
the numerical calculations of $S_{\perp}({\bm{q}},\omega)$ for $J_{1}=-1.0$
and $J_{2}=-0.1$ in the systems for $N_{L}=N_{1}^{3}$ with $N_{1}=8$, 16, 32,
64, and 128. We have confirmed that the results in $N_{1}=64$ and 128 are
almost the same and the result for $D=50$ in the system with $N_{1}=128$ is
shown in Fig. 6. Here, the intensity of $S_{\perp}({\bm{q}},\omega)$ is
plotted for ${\bm{q}}$ along the symmetry line (orange line) illustrated in
the inset of Fig. 4.

Figure 6:  The intensity plot of the dynamical structure factor
$S_{\perp}({\bm{q}},\omega)$ for $D=50$ at $J_{1}=-1.0$ and (a)$J_{2}=-0.1$
and (b) $J_{2}=-0.2$ where ${\bm{q}}$ is plotted along the symmetry line
illustrated in the inset of Fig. 4.

In Fig. 6, the high intensity appears in the lowest-energy branch along the
$\Gamma$-X line and also in the second-lowest energy branch along the
R-$\Gamma$-M line. The relatively-high to moderate intensities appear in the
lowest- and second-lowest-energy branches along the X-M-R line. We confirmed
that this feature appears for
$D\mathop{\vtop{\halign{#\cr$\hfil\displaystyle{>}\hfil$\crcr\kern
1.0pt\nointerlineskip\cr$\,\sim$ \crcr\kern 1.0pt\cr}}}\limits 2$ by
calculating $S_{\perp}({\bm{q}},\omega)$ on the basis of the linear-spin-wave
theory applied to the hedgehog-antihedgehog order.

Since it was shown that the hedgehog-antihedgehog order is realized for
$J_{2}/J_{1}<0.284$ in the effective magnetic model which corresponds to the
large-$D$ limit of the model (1) in Ref. WSR , we have discussed the results
of the linear spin-wave theory for $J_{1}=-1.0$ and $J_{2}=-0.1$ as the
typical parameters. Here, the $J_{2}$ dependence of the results is discussed.
We have calculated the dynamical structure factor $S_{\perp}({\bm{q}},\omega)$
as well as the excitation energy $\omega_{m^{\prime}}({\bm{q}})$ for various
$J_{2}/J_{1}<0.284$ with the FM interaction $J_{1}<0$.

We calculated $S_{\perp}({\bm{q}},\omega)$ of the excitation from the
hedgehog-antihedgehog order for $J_{2}=-0.2$, as shown in Fig. 6(b). The
energy dispersion and the intensity of $S_{\perp}({\bm{q}},\omega)$ are almost
similar to the result for $J_{2}=-0.1$ shown in Fig. 6, where all blanches are
slightly shifted to smaller $\omega$, i.e., the lowest-excitation energy is
$\omega/(S|J_{1}|)=97.56$ and the highest-excitation energy is
$\omega/(S|J_{1}|)=105.5$.

##  V Summary and Discussion

We have theoretically analyzed the dynamical structure factor as well as the
static structure factor in the hedgehog-antihedgehog order in the 1/1 AC.

We have shown that the static structure factor $F_{s}({\bm{q}})$ is generally
expressed as the convolution form $F_{s}({\bm{q}})=F_{L}({\bm{q}})S_{2{\rm
IC}}({\bm{q}})$ of the lattice structure factor $F_{L}({\bm{q}})$ and the
magnetic structure factor of the 2 ICs $S_{2{\rm IC}}({\bm{q}})$ in the unit
cell. In the bulk limit, $F_{s}({\bm{q}})$ can have a finite value for
${\bm{q}}=\frac{2\pi}{a}(h,k,l)$ with integer $h$, $k$, and $l$ because of the
requirement from the lattice structure factor $F_{L}({\bm{q}})$. By the
numerical calculation for the hedgehog-antihedgehog ordered state, we have
shown that the systematic absence of reflection $F_{s}({\bm{q}})=0$ occurs for
${\bm{q}}=\frac{2\pi}{a}(h,k,l)$ for case that all $h$, $k$, and $l$ are even
integers or one of $h$, $k$, and $l$ is even integer. This extinction rule and
the distribution of the intensities of $F_{s}({\bm{q}})$ revealed in this
study is useful for identifying the hedgehog-antihedgehog order
experimentally.

On the basis of the linear spin-wave theory, we have analyzed the excitation
energy and the dynamical structure factor by introducing the effective
magnetic model with uniaxial anisotropy $D$ arising from the CEF. The results
for large $D$ show that the reciprocal energy dispersion emerges, which is
understood as the symmetry argument that the hedgehog-antihedgehog ordering
preserves the spatial inversion symmetry. This is in sharp contrast to the
emergence of the non-reciprocal excitations in the uniform hedgehog order in
the 1/1 AC and QC where the spatial inversion symmetry is broken by the
hedgehog ordering. The high intensity of $S_{\perp}({\bm{q}},\omega)$ appears
in the low-energy branch in the vicinity of the $\Gamma$ point along the
$\Gamma$-X line and the R-$\Gamma$-X line.

So far, the hedgehog and antihedgehog states have been theoretically shown in
the 1/1 AC and QC WSR ; WPNAS  but have not been observed experimentally. To
observe the dynamical as well as the static structure factor shown in this
paper, it is necessary to identify the material which shows the hedgehog-anti-
hedgehog state in the 1/1 AC.

The CEF in the Au-SM-Tb (SM=Si, Ge, Al, and Ga) was analyzed theoretically on
the basis of the point charge model in refs. WSR  and WPNAS . It was shown
that as the ratio of the valences of the screened ligand ions $\alpha\equiv
Z_{\rm SM}/Z_{\rm Au}$ surrounding the Tb3+ ion varies, the direction of the
magnetic easy axis at each Tb site changes. This suggests that by changing the
compositions of the non-rare earth elements in the ternary compounds Au-SM-Tb,
there is the possibility that the hedgehog state and anti-hedgehog state are
realized. It is also noted that the CEF in the Au-Al-Yb was analyzed
theoretically in ref. WK2021 . It was shown that the tendency of the $\alpha$
dependence of the magnetic easy axis in the CEF ground state is different from
that in the Au-SM-Tb systems. Hence, there also exists the possibility that in
the 1/1 AC Au-SM-R with the other rare-earth element(s), the hedgehog-anti-
hedgehog state is realized. Hence, the synthesis of the rare-earth based Au-
SM-R compounds is interesting future subject to realize the hedgehog-anti-
hedgehog state.

Since the effective model for magnetism (1) is considered to be relevant to
the broad range of the rare-earth based ACs not only for Tb but also for the
other rare-earth atoms, the results of the dynamical as well as static
structure factor clarified in the present study are expected to be useful for
identifying the hedgehog-antihedgehog order in the 1/1 AC. Moreover, the
observation of the magnetic dynamics of the “spin” structures on the IC has
neither been reported in the icosahedral QCs and ACs, thus far. The present
study is expected to stimulate future experiments to detect the dynamical as
well as static structure factor in the unique magnetic structure with the non-
collinear and non-coplanar alignments of “spins” in the icosahedral 1/1 ACs
and also QCs.

###### Acknowledgements.

The author thanks H. Harima and T. Ishimasa for valuable discussion. The
author greatly acknowledges K. Momma for providing the VESTA to draw magnetic
moments in the 1/1 AC with kind instructions. This work was supported by JSPS
KAKENHI Grant Numbers JP18K03542, JP19H00648, JP22H04597, JP22H01170, and
JP23K17672.

## References

  * (1) D. Shechtman, I. Blech, D. Gratias, and J. W. Cahn, Phys. Rev. Lett. 53, 1951 (1984).
  * (2) A. P. Tsai, J. Q. Guo, E. Abe, H. Takakura, and T. J. Sato, Nature 408, 537 (2000).
  * (3) H. Takakura, C. P. Gómez, A. Yamamoto, M. De Boissieu, and A. P. Tsai, Nat. Mat. 6, 58 (2007).
  * (4) S. Suzuki, A. Ishikawa, T. Yamada, T. Sugimoto, A. Sakurai, and R. Tamura, Mater. Trans. 62, 298 (2021).
  * (5) R. Tamura, Y. Muro, T. Hiroto, K. Nishimoto, and T. Takabatake, Phys. Rev. B 82, 220201(R) (2010).
  * (6) A. Mori, H Ota, S. Yoshiuchi, K. Iwakawa, Y. Taga, Y. Hirose, T. Takeuchi, E. Yamamoto, Y. Haga, F. Honda, R. Settai, and Y. $\bar{\rm O}$nuki, J. Phys. Soc. Jpn. 81, 024720 (2012).
  * (7) A. Ishikawa, T. Fujii, T. Takeuchi, T. Yamada, Y. Matsushita, and R. Tamura Phys. Rev. B 98, 220403(R) (2018).
  * (8) T Hiroto, G. H. Gebresenbut, C. P. Gomez, Y. Muro, M. Isobe, Y. Ueda, K. Tokiwa, and R. Tamura, J. Phys.: Condens. Matter 25, 216004 (2013).
  * (9) T Hiroto, K. Tokiwa, and R Tamura, J. Phys.: Condens. Matter 26, 216004 (2014).
  * (10) A. Ishikawa, T. Hiroto, K. Tokiwa, T. Fujii, and R. Tamura, Phys. Rev. B 93, 024416 (2016).
  * (11) P. Das, P.-F. Lory, R. Flint, T. Kong, T. Hiroto, S. L. Bud’ko, P. C. Canfield, M. de Boissieu, A. Kreyssig, and A. I. Goldman, Phys. Rev. B 95, 054408 (2017).
  * (12) A. I. Goldman, T. Kong, A. Kreyssig, A. Jesche, M. Ramazanoglu, K. W. Dennis, S. L. Bud’ko, and P. C. Canfield, Nat. Mater. 12, 714 (2013).
  * (13) R. Tamura, A. Ishikawa, S. Suzuki, T. Kotajima, Y. Tanaka, T. Seki, N. Shibata, T. Yamada, T. Fujii, C.-W. Wang, M. Avdeev, K. Nawa, D. Okuyama, and T. J. Sato, J. Am. Chem. Soc. 143(47), 19938 (2021).
  * (14) R. Takeuchi, F. Labib, T. Tsugawa, Y. Akai, A. Ishikawa, S. Suzuki, T. Fujii, and R. Tamura, Phys. Rev. Lett. 130, 176701 (2023).
  * (15) T. Hiroto, T. J . Sato, H. Cao, T. Hawai, T. Yokoo, S. Itoh, and R. Tamura, J. Phys.: Condens. Matter 32, 415802 (2020).
  * (16) G. H. Gebresenbut, T. Shiino, M. S. Andersson, N. Qureshi, O. Fabelo, P. Beran, D. Qvarngard, P. Henelius, A. Rydh, R. Mathieu, P. Nordblad, and C. P. Gomez, Phys. Rev. B 106, 184413 (2022).
  * (17) T. J. Sato, A. Ishikawa, A. Sakurai, M. Hattori, M. Avdeev, and R. Tamura, Phys. Rev. B 100, 054417 (2019).
  * (18) S. Watanabe and M. Kawamoto, J. Phys. Soc. Jpn. 90, 063701(2021).
  * (19) S. Watanabe, Sci. Rep. 11, 17679 (2021).
  * (20) N. Kanazawa, Y. Nii, X. -X. Zhang, A. S. Mishchenko, G. De Filippis, F. Kagawa, Y. Iwasa, N. Nagaosa, and Y. Tokura, Nat. Commun. 7, 11622 (2016).
  * (21) Y. Tokura and N. Kanazawa, Chem. Rev. 121, 2857 (2021).
  * (22) S. Watanabe, Proc. Natl. Acad. Sci. USA. 118(43), e2112202118 (2021).
  * (23) S. Watanabe, Sci. Rep. 12, 15514 (2022).
  * (24) Y. Kato, S. Hayami, and Y. Motome, Phys. Rev. B 104, 224405 (2021).
  * (25) R. Eto, R. Pohle, and M. Mochizuki, Phys. Rev. Lett. 129, 017201 (2022).
  * (26) M. de Boissieu., S. Francoual, M. Mihalkovič, K. Shibata, A. Q. R. Baron, Y. Sidis, T. Ishimasa, D. Wu, T. Lograsso, L. P. Regnault, F. G$\ddot{\rm a}$hler, S. Tsutsui, B. Hennion, P. Bastie, T. J. Sato, H. Takakura, R. Currat, and A. P. Tsai, Nat. Mater. 6, 977 (2007).
  * (27) J. A. Ashraff and R. B. Stinchcombe, Phys. Rev. B 39, 2670 (1989).
  * (28) J. A. Ashraff, J. M. Luck, and R. B. Stinchcombe, Phys. Rev. B 41, 4314 (1990).
  * (29) S. Wessel and I. Milat, Phys. Rev. B 71, 104427 (2005).
  * (30) S. Watanabe, in preparation.
  * (31) S. Watanabe, Sci. Rep. 13, 14438 (2023).
  * (32) J. T. Haraldsen and R. S. Fishman, J. Phys.: Condens. Matter 21, 216001 (2009).
  * (33) T. Holstein and H. Primakoff, Phys. Rev. 58, 1098 (1940).
  * (34) J. H. P. Colpa, Physica A 93, 327 (1978).
  * (35) G. L. Squires, Introduction to the theory of thermal neutron scattering, 3rd ed. (Cambridge university press, 2012).
  * (36) S. Watanabe, Sci. Rep. 12, 10792 (2022).


# Fine tuning LLMs for Enterprise: Practical Guidelines and Recommendations

Mathav Raj J
HCLTech
Bengaluru
<EMAIL_ADDRESS>
&Kushala VM
HCLTech
Bengaluru
<EMAIL_ADDRESS>
&Harikrishna Warrier
HCLTech
Bengaluru
<EMAIL_ADDRESS>
&Yogesh Gupta
HCLTech
Bengaluru
<EMAIL_ADDRESS>

###### Abstract

There is a compelling necessity from enterprises for fine tuning LLMs (Large
Language Models) to get them trained on proprietary domain knowledge. The
challenge is to imbibe the LLMs with domain specific knowledge using the most
optimial resource and cost and in the best possible time. Many enterprises
rely on RAG (Retrieval Augmented Generation) which does not need LLMs to be
fine-tuned but they are limited by the quality of vector databases and their
retrieval capabilities rather than the intrinsic capabilities of the LLMs
themselves. In our current work we focus on fine tuning LLaMA, an open source
LLM using proprietary documents and code from an enterprise repository and use
the fine tuned models to evaluate the quality of responses. As part of this
work, we aim to guide beginners on how to start with fine tuning an LLM for
documentation and code by making educated guesses on size of GPU required and
options that are available for formatting the data. We also propose pre
processing recipes for both documentation and code to prepare dataset in
different formats. The proposed methods of data preparation for document
datasets are forming paragraph chunks, forming question and answer pairs and
forming keyword and paragraph chunk pairs. For code dataset we propose forming
summary and function pairs. Further, we qualitatively evaluate the results of
the models for domain specific queries. Finally, we also propose practical
guidelines and recommendations for fine tuning LLMs.

_K_ eywords Fine tuning guidelines $\cdot$ Code dataset $\cdot$ Document
dataset

##  1 Introduction

The advent of LLMs has revolutionised natural language processing.
Applications are varying from language translation [1], content creation [2]
and to emotional support chatbots [3]. LLMs like LLaMA have been trained on
trillions of tokens[4] from various resources. To adapt a general purpose LLM
for one of these specific tasks, it has to be trained on task oriented
dataset. This additional training allows the model to fine tune its parameters
to the task or domain we are interested in. Models like FinGPT for finance
domain [5], PMC-LLaMA for medical domain [6] are fine tuned on particular
domain datasets to achieve improved accuracy on domain related questions.
Domain specific LLMs can be helpful in scenarios such as support ticket
resolution, querying document base or code repository to adapt into new system
etc. Though there is an option to use OpenAI models to solve most of the use-
cases, there is a high demand for domain specific LLMs due to data privacy and
pricing concerns. The stake holder’s dataset can stay on premise as the LLMs
are also present on premise. Fine-tuned LLMs provide quality and custom feel
to the stake holder and also has low latency in displaying the results.

This paper aims to enable a beginner in preparing the data for fine tuning,
estimating the compute capability and memory needed, choosing the right
dataset format and the optimal configurations for fine tuning. The paper is
arranged as follows:

  * •

Research Background: A short survey on related research work on fine tuning vs
RAG, fine tuning guidelines, efficient techniques for fine tuning and
preparation of datasets for fine tuning

  * •

Fine tuning configurations: Before starting the fine tuning process it is
necessary to understand what configurations can be adjusted to run on
available resources.

  * •

Proposed Dataset formats for Text and Code: The overall workflow of the
proprietary data fine tuning is detailed in this section. The different
proposed formats of text and code data has been explained in detail

  * •

Experiments: A proprietary document and code repository is used to showcase
the fine tuning work flow. Empirical studies have been conducted to understand
the effects of quantization on time and memory, to understand the selection of
appropriate rank in LORA (Low Rank Adapater) fine tuning, understand the
memory requirements for full model fine tuning and to understand the effects
of fine tuned model in a Retrieval Augmented Generation (RAG) pipeline

  * •

Guidelines: In the final section, practical guidelines for fine tuning has
been given. Some tips to choosing right parameters for fine tuning efficient
techniques like LORA is also listed.

##  2 Research Background

The authors in [7] give an overall view of the recent trends in LLMs. LLMs can
be trained in different phases. The first phase being the pretraining with
defined objectives such as causal language modelling, masked language
modelling, span denoising objective etc. Then comes the transfer learning
phase which is further classified as feature based transfer and finetuning
approach. Transfer learning is required when the dataset is inadequate for a
complete training from scratch. Therefore pretrained weights are used as
starting point. In feature based transfer learning features obtained from the
pretrained model for the given domain dataset are used by another smaller
model to train. Meanwhile finetuning on a dataset is to nudge the pretrained
weights on a particular task oriented dataset. Depending on the how many
layers are fine tuned and how prompts are handled during finetuning, it is
further classified as adapter tuning, gradual unfreezing, prompt tuning etc.

An alternate approach to fine tuning is to chunk the documents, convert to
embeddings and store it in a vector database for retrieval using similarity
search with the query and use the pretrained LLM to come up with a
consolidated answer from the retrieved documents. [8]. This is the production
ready approach as it is fast and gives more or less exact results. However the
RAG approach can be crippled by a not so good retrieval mechanism. Though
there are simple alleviations like the claim in [9] that information retrieval
in RAG has improved by purposeful addition of noisy documents, the quality of
answers are limited by the similarity search which has nothing to do with the
LLM capability itself.

A study by [10] shows the comparison of between finetuning and RAG. The
experiments in the paper reveal that finetuning on a domain data extracted
from agriculture journals have given more succinct and accurate responses than
a RAG pipeline. That being said, the authors also have ackowledged the high
initial cost required to fine tune a model.

Low Rank Adaptation (LORA) finetuning of LLMs [11] has opened up a whole new
possibility of finetuning limited number of essential parameters usually of
the order of few thousands to a millions instead of the entire parameters
which is in the order of billions. The work on quantizing LLMs has opened up
avenues for resource deficient systems to train at low memory cost [12].
Papers on quantized LLMs in combination with parameter efficient techniques
like LORA have further enabled obtaining satisfactory results with low
resources[13].

Code generation with LLM is the most attractive task engineers are looking at.
Even though LLM are already trained with lots of data which makes them to
generate code depending on the input, the challenge is generating code about a
specific enterprise domain code. LLM fine-tuning for a specific task makes the
model utilize its capacity to fullest by making it adapt to a domain by making
the model familiar to jargons, domain terminology by understanding the context
of the code, class, functions, exceptions, libraries etc., Fine-tuning also
helps in adapting the model to address the task specific problems. Fine-tuning
large language models for code-related tasks presents a myriad set of
challenges that must be carefully addressed to ensure optimal performance and
reliability. The challenges encompass aspects such as data quality and
quantity, domain-specific understanding, tokenization and vocabulary,
contextual understanding, code generation quality, code understanding vs.
generation, model size and computational resources, overfitting and
generalization, evaluation metrics, and ethical and security concerns.

##  3 Fine Tuning LLMs on Available Resources

###  3.1 Quantization

By default, most open source LLM weights are released in full 32 bit floating
point precision. Even for fine tuning a model of relatively smaller size say 7
billion parameters, nearly 28 GB space is required. With higher precision
weights, compute units have to spend higher energy in memory movement
operations during fine tuning [14]. Quantization is the process of
constraining an input from continuous set of values to a discrete set.
Quantizing the model weights to a lower precision and fine tuning greatly
reduces the size without hampering the quality [12].

Data is stored in different numeric types namely: FP32, FP16, int8, FP8, BF16.
Integers can be represented in unsigned or signed format or 2’s complement
form. To represent a fractional decimal we could go for a fixed point
representation. To further extend the range, systems use the IEEE 754 floating
point representation which has a much larger range since the numbers are
expressed in exponents of 2. The 32 bits of floating point representation has
three parts namely 1 sign bit, 8 bits for exponent (both positive and
negative) and 23 bits for mantissa or significant figures. The width of the
exponent bits determines the range of numbers and the width of the mantissa
bits determines the precision of numbers. Based on the widths there are
different forms. Different forms may be needed based on the availability of
memory resources. FP16 reduces both the range and precision by using 5 bits
for exponent and 10 bits for mantissa. Brain float 16[15] or BF16 maintains
the same range as FP32 but reduction of precision to 7 bits. Floating point 16
or FP16 enables training of larger models or training with larger mini-
batches.

With neural networks, quantization can be done with the weights during storage
and activation during the computation. Quantization (QAT) and post training
quantization (PTQ). Integer quantization favours memory reduction and thereby
energy and cost reduction during inference [14]. In a QAT scheme proposed by
Jacob et al. [16], the quantization errors are included in the computation
graph during fine tuning so that the model’s inference performance can be as
if it were never quantized. This allows for deployment of models in edge
hardware that support only integer arithmetic.

Tim Dettmers et al. propose a new type of integer quantization scheme called
LLM int8 [12]. This has been implemented in the python library ’bitsandbytes’.
To explain in a more detailed manner, quantization is a two step process that
involves i) Finding the normalization constant and scale the vector into
target range ii) Rounding off to the nearest value in target range. During
matrix multiplication of tensors, quantization of weights with outliers will
lead to huge quantization loss. To mitigate this, bitsandbytes employs a
combination of vector wise quantization and mixed precision decomposition to
achieve a performance similar to that without quantization. Though LLM int8
quantization does not degrade performance, the inference time gets increased
due to the overhead of quantization [17]. However the memory gets reduced
drastically by 71%, which is major cost saving when choosing cloud premise
GPUs.

###  3.2 Gradient Accumulation

Other than quantization, techniques like gradient accumulation help in
reducing the memory requirement during fine tuning. The process of
accumulating gradients in the context of backpropagation involves a strategic
approach to parameter updates within a neural network during the training
phase. Unlike the conventional method where parameters are updated after
processing each mini-batch, the accumulation of gradients entails deferring
the parameter updates until all the instances in a mini-batch have been
processed.

In the standard back propagation algorithm, the gradients computed for each
instance in a mini-batch are typically used to immediately update the model
parameters. However, in the case of accumulated gradients, these individual
gradients are not immediately applied to the parameters. Instead, they are
summed or averaged over the entire mini-batch. As each instance in the mini-
batch undergoes forward and backward passes, the gradients with respect to the
model parameters are computed but not immediately applied. These gradients are
stored, and the accumulation occurs over the entire mini-batch. Only when all
instances in the mini-batch have been processed, the accumulated gradients are
employed to update the model parameters. This aggregated update is akin to the
effect of utilizing a higher batch size for training the neural network.

###  3.3 PEFT (Parameter Efficient Fine Tuning)

Large language models get more efficient with transfer learning through fine
tuning. But on the other hand, fine tuning becomes challenging with respect to
the infrastructure needed, time required and overall memory needs. To overcome
these challenges, parameter efficient fine tuning comes into picture.
Parameter-efficient Fine-tuning (PEFT) is a technique used in Natural Language
Processing to improve the performance of pre-trained language models on
specific downstream tasks. It involves reusing the pre-trained model’s
parameters and fine-tuning them on a smaller dataset, which saves
computational resources and time compared to training the entire model from
scratch. PEFT achieves this efficiency by freezing some of the layers of the
pre-trained model and only fine-tuning the last few layers that are specific
to the downstream task. There are many methods in PEFT training: Adapter,
LoRA, QLoRA, Prefix tuning, Prompt tuning, P-tuning, and IA3. In this paper,
we will be delving on LoRA and QLoRA methodology of training.

LoRA, [11] a method for fine-tuning large language models, operates by
integrating small trainable submodules alongside feed-forward layers in the
pre-trained transformer architecture. These LoRA modules employ rank
decomposition to significantly reduce the number of trainable parameters while
maintaining or even enhancing model performance across various tasks.
Specifically, LoRA inserts two feed-forward layers adjacent to each feed-
forward layer in the transformer model, where the first layer projects the
input into a lower-dimensional space and the second layer restores it to the
original dimensionality. This incremental change, represented as delta h, is
added to the original hidden representation, resulting in an updated
representation h’. Through this approach, task-specific parameters are
minimized, facilitating efficient task-switching and reducing hardware
requirements without introducing additional inference latency.

QLoRA, or quantized LORA, is an optimized version of LoRA, where the precision
of the weight parameters are reduced to 4 bit precision. Since QLoRA shrinks
the model size due to the reduced precision, it is helpful in scenarios where
there is limited memory to fine tune.

##  4 Fine Tuning Workflow

The workflow for fine tuning an LLM, be it for text or code, can be
represented as in Figure 1 below.

Figure 1: Fine tuning Workflow (with LLaMA model as an example)

Unstructured text or code is fed to the first stage of fine tuning, the pre-
processing recipe. Based on the recipe, it chunks the data into logical parts
and then it is tokenized (and padded where needed) so that it accomodates the
supported sequence lenght of the model. Further, the LoRA / QLoRA
configurations are applied and fine tuning is done till the loss is minimized.
This is the standard process of fine tuning. Thus, we can see that the key
step in fine tuning is the data pre-processing, and the quality of fine tuning
is primarily dependent on that. So, we will describe that in more detail
below.

###  4.1 Text Data Pre-Processing

This step plays a vital role in fine tuning process. From scratch, a Large
language model is trained to do next token prediction. The datasets are
massive text corpus like Common crawl, The Pile and code repositories from
Github. Further the model can be fine tuned for specific tasks using
specialised datasets. One such series of datasets are called Instruction
datasets like Dolly, Orca, Alpaca and Vicuna. All these datasets enable
instruction fine tuning. Instruction fine tuning bridges the gap between next
token prediction and user’s requirement of following instruction prompts[18].
An instruction dataset consists of instruction prompt, response paired with or
without context for additional information. The challenge is how to create an
instruction dataset from a general document.

As part of our experiments, we developed fine tuning datasets pre-processing
recipes of four different formats namely a) raw data b) keywords as
instruction c) headings as instruction and d) queries as instruction.

For a decoder model like LLaMA 2, the raw format is essentially continuing the
initial training objective of unsupervised next token prediction with raw
text. In the raw data method, we are passing the document as raw chunks with
no template.

In the keywords method, we are passing the chunks in a template with prompt
being keywords extracted from the chunk. For this, we used Rapid Automatic
Keyword Extraction (RAKE) algorithm (the corresponding python library being
rake-nltk[19]).

Another method is to use the document headings with different headings levels
as prompt. As an example, in cases of Microsoft Word docx documents, the
document parser from llm search[20] is used.

The last methods that we used is a query based approach. This is particularly
usefuly when a user is interested in querying for information about the
document from the LLM, hence it is ideal if the prompt is also having queries.
The same model is used to generate possible queries that can be asked about a
chunk and then the dataset is prepared. A single chunk can have multiple
queries to promote diversity in the dataset.

When data set is not in a paired format, the challenge is how to structure the
data and let the model understand the given text. As a baseline, we split the
text into chunks of fixed length and trained the model with those chunks. The
objective of fine tuning the model is next token prediction. As a first step
the model encodes the splitted chunks into embeddings. LLaMA tokenizer is a
Byte Pair Encoding tokenizer model based on sentencepiece. Once the words are
tokenized, embedded and padded to appropriate fixed sequence length, the data
is ready to be fed to model for fine tuning.

In Fine tuning a paired dataset format, the input ids will be the
input+output+pad tokens and labels will be the ignore tokens+output+pad
tokens. Here we have essentially masked the length of input tokens and it will
not be considered while calculating the loss. The input ids and labels for the
transformer are the same except that in case of input ids the padding token is
<unk> and for labels it is -100.

The drawback in this approach is that the structure in the document such as
headings and topical information might not be present within a chunk. The
overlap option in Langchain splitters helps with this issue to an extent.
However some topical information are too long to be captured by just
overlapping.

###  4.2 Code Data Pre-processing

LLM models are trained such that higher the context, detailing and prompting
higher the results. When LLM are trained for code generation task it is very
important to make the model understand the domain with quality along with
quantity information. Researchers have been exploring the best possible way to
reduce the amount of effort required during the preparation of the data.

In our experiment we have considered three different ways of preparing the
training data. They are a) Summary method b) Metadata method and c)
Tokenization method

The first method involves splitting the code at a class level or functional
level code. The functional level code is considered as a source for preparing
the data. The entire code repository is split into function level code. The
functional level code is fed into the instruct model to generate the summaries
by prompting the model. This type of data becomes our generated dataset which
has function level code associated with their summaries.

The second method involves extracting information from the coding practices
embedded in the code. It is said that synthetic, structured, high quality,
text book like data makes LLM learn faster and produce good results[21]. In
this approach, the comments and docstrings in the code are extracted along
with detailed comments and is used along with the raw information gathered
from the code as pre-processing data.

The third method involves tokenizing the whole code base irrespective of the
file type into the supported sequence length. This method doesn’t involve
gathering any other data. The LLM model with this tokenized data is trained
for the purpose of next token prediction usecase.

###  4.3 Compute Estimation

After deciding on the input, the expected output and objective at hand, the
next step is to decide on the hardware. To get the memory that will be
occupied by a model in FP32 precision a rough estimate is to multiply the
model parameter size by 4, since a single parameter occupies 4 bytes. For
FP16, the multiplication factor is 2, and for 8 bit quantized model it is 1
and hence for 4 bit it is 0.5. This estimate alone will not help us in finding
the right hardware for fine tuning as a higher percentage of memory is
required to store the gradients and activations during the fine tuning
process. This additional storage also has to be accounted for.

##  5 Experiments

LLaMA 2, the open source model used for experimentation in this paper has a
pre training data cut off time on September 2022. Additional data till July
2023 has also been added as fresh data during fine tuning before its release
[4]. Hence to test the approaches of data preparation recipes, proprietary
documents and code repositories were used from our inhouse machine learning
platform.

A100 80 GB Nvidia GPU from Google Cloud Platform is used as the hardware
accelerator for the fine tuning process.

###  5.1 Text

To fine tune with text data, documentation resources from our machine learning
platform were used. The user guide of this platform which has 66 pages and 5
MB of data was used as the raw source of data. This was converted to 60 KB csv
file with 33 rows. Since the document is not available to public and was also
created after the fine tuning cut off time of the original LLaMA 2 model, it
makes a good dataset to study. The user guide is in PDF format and the content
is well structured with index, headings and step by step instructions.

Before the start of fine tuning process, the influence of quantization on
inference is shown in table 1. Quantizing a model saves on GPU memory and
allows fine tuning with higher batch sizes there by reducing time and money
spent on the training job. However as shown in figure 2, quantized model on
average takes a higher time for inference compared to a non quantized model.

Figure 2: Inference time of fine tuned Llama 2 7B Chat model

Table 1: Influence of quantization on inference Quantization | GPU memory |  What is AION?
---|---|---
Without quantization | 28 GB |  AION (Artificial Intelligence ON) is a cloud-based platform that enables developers to build, train and deploy machine learning models. It provides an end-to-end solution for data scientists and engineers to create, test, refine, and deploy ML models in production environments.
8 bit quantization | 8 GB |  AION (Artificial Intelligence ON) is a cloud-based platform that enables developers to build, train and deploy machine learning models. It provides an end-to-end solution for data scientists and engineers to create, test, refine, and deploy predictive modeling solutions in the form of APIs or containerized microservices.

In table LABEL:tab:llamatable, the maximum possible configurations of PEFT
methods on a A100 80 GB GPU machine are listed. For example, 70 B parameter
flavour of LLaMA 2 model can be fine tuned only with QLoRA in 80 GB machine.
LORA is not possible due to memory constraint.

[ caption = Maximum possible PEFT configurations of Llama 2 models on A100 80
GB, label = tab:llamatable, ]hlines, vlines, colspec = l *9c  Model & size &
Dataset size Epochs PEFT method CPU memory GPU memory Estimated time
Llama 2 Chat 7B 60 KB 3 LORA 6 GB 18 GB 15 mins
Llama 2 Chat 13B 60 KB 3 LORA 6 GB 26 GB 25 mins
Llama 2 Chat 70B 60 KB 3 QLORA 7 GB 65 GB 40 mins

Now with the understanding of PEFT configurations possible for different size
models, next there is a need to tune the PEFT hyper parameters. In [11], alpha
is suggested to be fixed and rank is fine tuned. Typically lower ranks are
preferred with a number of target modules. However owing to a smaller dataset
size, target modules were kept as q_proj and v_proj only. A high alpha is used
so that model could learn more from new gradient updates pertaining to the new
information from documentation. The quality of the responses are captured with
a manual assessment. As evident from table 2, the appropriate rank and alpha
that gives decent results vary for the different parameter sized models.

Table 2: LoRA rank tuning Model and size | LoRA parameters | Prompt Manual assessments
---|---|---
|  Rank |  Alpha |  Qn1 |  Qn2
7B Chat |  1 |  512 |  Good |  Good
|  2 |  512 |  Average |  Poor
|  4 |  512 |  Poor |  Poor
|  8 |  512 |  Poor |  Poor
|  16 |  512 |  Poor |  Poor
13B Chat |  1 |  512 |  Poor |  Good
|  2 |  512 |  Poor |  Average
|  4 |  512 |  Poor |  Good
|  8 |  512 |  Good |  Good
|  16 |  512 |  Average |  Average

With data extracted from the pdf, the final dataset is prepared in four ways
and it is clear that each variation of the data preparation recipe produces
different small changes in the response. ’Raw’ and ’Keyword’ recipe give short
and succinct responses. ’Heading’ and ’Summary’ methods give a somewhat
detailed response.

Table 3: Influence of data preparation recipes on inference Dataset type |  What is AION?
---|---
Default |  AION (Artificial Intelligence ON) is a cloud-based platform that enables developers to build, train and deploy machine learning models. It provides an end-to-end solution for data scientists and engineers to create, test, refine, and deploy predictive modeling solutions in the form of APIs or containerized microservices.
ML |  AION (AI-ON) is an open source platform for building, deploying and managing machine learning models at scale. It provides features such as data version control, reproducibility, collaboration support, model monitoring, and deployment to cloud or on premise infrastructure.
Meta Data |  AION (Artificial Intelligence ON) is an open-source, cloud-native platform for building and deploying modern machine learning models at scale. It provides a unified environment to develop, train, test, and deploy ML models across different data sources and platforms. The main goal of AION is to make it easy for developers to build, manage, and monitor their ML workflows by automating most of the underlying tasks such as data ingestion, feature engineering, model training,
Gen AI |  AION (Artificial Intelligence ON): It refers to the integration of machine learning, data analytics, robotics, and artificial intelligence to automate business processes, improve productivity, and enable more informed decisions.AION stands for Artificial Intelligence ON which means all the features such as ML, Deep Learning, etc are enabled by default without any need to disable them. This makes it easy to use and deploy models in production environments seamlessly.

PEFT methods are recommended for smaller dataset. However if there is a huge
collection of dataset with new information, full fine tuning of all the
parameters of a model is possible. The A100 80 GB GPU is capable of supporting
full model fine tuning of 7B and 13B models. In table LABEL:tab:fulltable the
loading parameters and batch size details are given in detail. Higher batch
sizes gave cuda out of memory error. The configurations in each row of each of
the model size are named as config A, B and C respectively. In 3, a graph is
plotted between number of data rows and the training time. With increase in
data rows, the time increases linearly. A different configuration with higher
batch size and gradient accumulation steps will decrease the fine tuning time
slightly. A huge time will be saved if full fine tuning is done for half the
total capacity of maximum sequence length of LLaMA 2 models.

[ caption = Full fine tuning of Llama2 Chat on A100 80 GB, label =
tab:fulltable, ]hlines, vlines, colspec = l *9c  Llama2 Chat Model size & Data
size Seq len Model precision Batch size Gradient accumulation steps Resulting
steps CPU memory GPU memory Estimated time (mins)
7B 60 KB 4096 FP32 1 2 254 54 GB 80 GB 57
7B 60 KB 4096 FP16 2 4 63 54 GB 80 GB 33
7B 60 KB 2048 FP16 4 8 16 54 GB 80 GB 10
13B 60 KB 4096 FP32 1 2 254 102 GB 80 GB 110
13B 60 KB 4096 FP16 2 4 127 102 GB 80 GB 75
13B 60 KB 2048 FP16 4 8 16 102 GB 80 GB 25

RAG- (Retrieval Augmented Generation) is a popular way of using embeddings and
a vector similarity search to find only relevant context from a pool of
documentation with new information or any content longer than maximum capacity
of the LLM. The LLM interprets the context and gives a polished response. This
entire process can be summed as embedding conversion followed by similiarity
search usually through a vector DB which in turn is followed by LLM handling
the context. It is evident from this process that the contribution of LLM will
be good only if the contexts obtained are good. A comparison is made in table
LABEL:tab:ragvsft between RAG with a pretrained model and RAG with the fine
tuned model. It is seen that RAG responses are improved with specific answers
and even following the style of the document. Since the document being dealt
here is a user guide there are steps mentioned in every process. Only the fine
tuned model was able to follow this pattern of giving responses in step by
step format. Another observation is regarding the last question which is a
multi part question. The last question was not answered by the base LLaMA 2
model. Our fine tuned model was not only able to follow the style but also
give the precise answer to the second part of the question. Hence fine tuning
could be one solution to hallucinations in RAG.

(a) 7B Chat model full fine tuning

(b) 13B Chat model full fine tuning

Figure 3: Fine tuning time of Llama 2 Chat models on different fine tuning
configurations

Table 4: Retrieval Augmented Generation with LLaMA 2 Chat before and after fine tuning Questions |  RAG |  Finetuned model and RAG
---|---|---
What is AION? |  Based on the provided context, I can confirm that AION is an artificial intelligence (AI) life cycle management platform designed to help organizations apply machine learning to real-world problems. AION provides a comprehensive suite of tools and services for managing the entire AI lifecycle, including data ingestion, exploratory data analysis, data processing, feature selection, model training and hyperparameter tuning, and inference services. The platform offers a less-code/no-code approach, allowing business users to generate ML models without coding. Additionally, AION includes explainability capabilities to provide higher accuracy predictions with supported explanations and model confidence. |  Based on the provided context, I can explain what AION is. AION stands for Artificial Intelligence ON, which is an AI life cycle management platform used for solving real-world problems using machine learning. AION provides a less-code/no-code approach to users, allowing them to train and deploy machine learning models without any coding knowledge. It includes various sub-processes such as AutoML, MLOPs, MLaC, and Explainability. These sub-processes are automated, and AION generates the best deployment model after analyzing the input data and problem statement.
Write in detail about MLLite feature in AION. List the input model formats that can be converted to ONNX. |  Based on the provided context, here is the information regarding the MLLite feature in AION: MLLite is a feature in AION that allows users to convert their trained models into formats compatible with various deep learning frameworks, including ONNX and TFLite. The main purpose of MLLite is to enable efficient inference execution on different devices without requiring significant modifications to the original model architecture. Regarding the input model formats that can be converted to ONNX, according to the context, the following formats are supported:Keras, Sklearn, TensorFlow, TFLite, Light GBM, XGBoost, LibSVM,CoreML In summary, MLLite is a useful feature in AION that enables users to convert their trained models into optimized formats for efficient inference execution on various devices, while also providing support for multiple input model formats for conversion to ONNX. |  Sure! Here’s what I could gather from the given text regarding the MLLite feature in AION:MLLite feature in AION allows users to convert their trained models into different formats such as ONNX, TFLite, and Sagemaker. The main advantage of this feature is that it enables users to consume these optimized models for predictions without having to retrain them.Input Model Formats that can be converted to ONNX include:Keras,Sklearn,TensorFlow,Light GBM,XGBoost,LibSVM, CoreML
Is there Incremental learning in AION? If so what are the steps to create an incremental model? |  Yes, AION supports incremental learning for regression and classification problems. To create an incremental model in AION, follow these steps: 1\. Select the "Online Learning" (Beta) or "Distributed Learning" (Beta) checkbox in the Incremental Learning section of the configuration page. 2\. Choose the problem type (Regression or Classification) that supports incremental learning. 3\. Proceed to the next step by clicking the "Next" button. In summary, to create an incremental model in AION, you need to enable online learning in the configuration page and choose the appropriate problem type. |  Yes, there is incremental learning in AION. To create an incremental model follow the below-mentioned steps: Step 2: Click online learning tab. Step 3: Select the Online Learning (Beta) or Distributed learning (Beta) checkbox for Incremental Learning. Step 4: Click next icon to proceed to advanced configuration tab.
How can we do text labelling with AION? Give the API URL for model monitoring? |  Based on the provided context, the API URL for model monitoring during text labeling with AION is not explicitly mentioned. Therefore, I cannot provide an answer to this question. |  Based on the provided context, I can answer the question as follows: To perform text labelling with AION, follow these steps: Step 1: Go to Utilities > Text Data Labelling. Step 2: Upload the text data in CSV format. Step 3: Select relevant features and click Next. Step 4: Generate predictions by clicking Predictions tab. The predicted labels are displayed under Predicted Labels section. For example, if the input text is "This is a sample text", the predicted label would be "positive". API URL for Model Monitoring: To monitor the performance of the model, users can use the API endpoint /monitoring/model-performance. This API returns the summary statistics of the model’s performance along with the confusion matrix. Example: curl -X POST http://localhost:8080/monitoring/model-performance -H ’Content-Type: application/json’ -d ’"data":["This is a sample text"],"label":["positive"]’

Finally the objective of the fine tuning process is to see if the LLM has
learnt the new knowledge and as shown in table 5, it indeed has learnt.

Table 5: Model learning new information after fine tuning

Fine tuning | Model |  What is AION?
---|---|---
Before | Llama 2 chat |  Aion (AION) is a blockchain-based platform that enables the creation and exchange of digital assets, such as NFTs. It was founded in 2018 by a team led by Matthew Roszak, who has extensive experience in the cryptocurrency industry.
After | Llama 2 chat |  AION (Artificial Intelligence ON) is a cloud-based platform that enables developers to build, train and deploy machine learning models. It provides an end-to-end solution for data scientists and engineers to create, test, refine, and deploy ML models in production environments.

###  5.2 Code

For the code dataset, JAVA files from a sustenance engineering solutions
platform was used. This being a closed source code repository, the codes are
new unlearned information for Llama models making it a good dataset to
experiment with. The total size of the code data was 16MB with a total
function count of 13807. The dataset was condensed and packed according to
token limit of LLaMA model and resulted in a csv file of 10 MB size with 60
rows.

[ caption = PEFT methods on Code Llama on A100 80 GB, label = tab:codet1,
]hlines, vlines, colspec = l *9c  Model & size & Data size Epochs PEFT method
CPU memory GPU memory Estimated time
Code Llama 7B 10 MB 3 LORA 6 GB 18 GB 23 mins
Code Llama 13B 10 MB 3 LORA 6 GB 26 GB 25 mins
Code Llama 7B 10 MB 3 QLORA 7 GB 15 GB 10 mins

Table LABEL:tab:codet1 exhibits the experiment on the hyper parameters
conducted to investigate the performance of the model. Few results are
discussed by prompting the trained model and comparing the results from the
code repository. It was seen from the results from the experiments the Code
LLaMA models gave an exceptionally good results with LoRA rank 16 and alpha
32. Higher the rank and alpha made the models to hallucinate and randomly
generate the code.

[ caption = Full fine tuning of Code Llama on A100 80 GB, label = tab:?,
]hlines, vlines, colspec = l *9c  Model & size & Seq len Model precision Batch
size Gradient accumulation steps CPU memory GPU memory Estimated time
Code Llama 7B 4096 FP16 2 2 54 GB 57 GB 10 mins
Code Llama 7B 4096 FP16 2 4 54 GB 46 GB 38 mins
Code Llama 7B 2048 FP16 4 8 54 GB 59 GB 10 mins
Code Llama 13B 4096 FP32 2 2 102 GB 53 GB 9 mins
Code Llama 13B 4096 FP16 2 4 102 GB 53 GB 18 mins
Code Llama 13B 2048 FP16 4 8 102 GB 62 GB 33 mins

Table 6: Code Llama LORA Model and size | LoRA parameters | Prompt Manual assessments
---|---|---
|  Rank |  Alpha |
Code Llama 7B |  2 |  4 |  Poor
|  4 |  8 |  Poor
|  8 |  16 |  Average
|  16 |  32 |  Good

Table 8: Code for getting testcase by ID

Prompt |  Ground truth |  Predicted response
---|---|---
A connection object is created to connect to a database for a given project name Connection is established to the database using the URL, username and password If an exception occurs the error message is printed The connection object is returned to the calling function |  ⬇ Connection con = null;  HttpServletRequest httpRequest = null;  try{  System.out.println(""get New Connection projectName:""+projectName) ;  Class. forName(driverName) .newInstance() ;  con = DriverManager.getConnection(url+projectName, dbUser, dbPass);  } catch (SQLException sqle) {  System.out.println(""in ConnectionPool of getNewConnection()11111""+sqle.getStackTrace());  } catch (Exception e) {  System.out.println(""in ConnectionPool of getNewConnection()222"");  e.printStackTrace();  }  return con;  |  ⬇ public Connection getConnection(String projectName){  Connection con = null;  HttpServletRequest httpRequest = null;  try{  Class.forName(driverName).newInstance();  con = DriverManager.getConnection(url+projectName, dbUser, dbPass);  } catch (SQLException sqle) {  System.out.println("In␣ConnectionPool␣of␣getConnection()"+sqle.getMessage());  }} catch (Exception e) {  System.out.println("In␣ConnectionPool␣of␣getConnection()"+e.getMessage());  }  return con;

Table 8: Code for getting testcase by ID

Prompt |  Ground truth |  Predicted response
---|---|---
Connect to the database. Prepare a query with a given test case ID to the table testcases table. Set the parameter to the given value. Execute the query and retrieve the results. Get the desired data from the results. Release resources used by the query and results. Return the desired data. |  ⬇ public List<DefectTestCaseMappingDTO> getFieldDefects(String testcaseId){  int tcIdPk = DeltaUploadDAO.getInstance().getTestCaseId(testcaseId);  List<DefectTestCaseMappingDTO> fieldDefectsList = new ArrayList<DefectTestCaseMappingDTO>();  Connection connection = ConnectionPool.getInstance().getConnection();  if(null != connection){  Statement stmt = null;  ResultSet rs = null;  try {  if(null != connection){  String sql = ""SELECT * FROM DEFECT_TESTCASE_MAPPING WHERE STATUS = ’R’ AND TESTCASE_ID_FK = ""+tcIdPk+"""";  stmt = connection.createStatement();  rs = stmt.executeQuery(sql);  while(rs.next()) {  DefectTestCaseMappingDTO defectDTO= new DefectTestCaseMappingDTO();  defectDTO.setTestCaseId(getTcById(rs.getInt(""TESTCASE_ID_FK"")));  defectDTO.setStatus(rs.getString(""STATUS""));  defectDTO.setAuto(rs.getString(""AUTO""));  defectDTO.setReviewed(rs.getString(""REVIEWED""));  fieldDefectsList.add(defectDTO);}}  }  }  return con;  |  ⬇ public DataSet getTestCaseByTestCaseId(int testCaseId){  System.out.println(’getTestCaseByTestCaseId’);  Connection con = null;  Statement stmt = null;  ResultSet rs = null;  DataSet ds = new DataSet();  try{  con = ConnectionProvider.getConnection();  if(null != con){  stmt = con.createStatment();  String sql = "SELECT␣*␣FROM␣TESTCASES␣where␣TESTCASE_ID_FK="+testCaseId+"";  while(rs.next()) {  TestCaseDAO tcDao = new TestCaseDAO();  tcDao.setTestCaseName(rs.getString("TESTCASE_NAME"));  tcDao.setTestCaseDesc(rs.getString("TESTCASE_DESC"));  tcDao.setTestCaseId(rs.getInt("TESTCASE_ID_FK"));  ds.add(tcDao);  }  return ds;  } catch (Exception e) {  }}}

##  6 Guidelines and Recommendations

The following guidelines and recommendations have been summarized below, based
on the various experiements that we have done on text and code fine tuning:

  * •

Empirically loading the model in half precision is sufficient to go ahead with
fine tuning and it also saves GPU memory to accommodate more batches if needed
to save on finetuning time

  * •

Unless there is an abundance of data, parameter efficient finetuning is
preferable than full finetuning. This also helps in creating easily moveable
low sized adapters tuned for different tasks or domains

  * •

Choose a model quantization level based on section 4.3. For example, consider
Llama 7B model in a 16 GB colab environment; in this scenario, 8 bit quantized
LORA fine tuning is possible but not full model fine tuning.

  * •

For full fine tuning, typically multiple GPUs are required. In case of a
constraint of having only one GPU available and a large CPU memory, it is
recommended to use paged adam optimizer

  * •

For small datasets, it is ideal to use LORA fine tuning. Rank and Alpha has to
be fine tuned

  * •

From the empirical experiments on text and code data, to make a language model
assimilate new information, lower rank and higher alpha is recommended

  * •

For large documents with text content of the order of few hundred MBs, it is
recommended to utilise the full sequence length capability of the model in
every row of data

  * •

Fine tuning time largely depends on the number of rows in dataset. If the text
content is chunked to full context length without padding, number of data rows
can be greatly reduced

  * •

Gradient accumulation steps is the number of steps after which the optimizer
is stepped. Until then gradients are accumulated over the batches. This is
good in distributed system but in single GPU it is slow

  * •

A higher batch size will lead to faster convergence and might give better
performance at inference. Batch size is recommended to be kept at a lower
value suitable for the model and not to the limiting value of GPU memory.

  * •

Higher the gradient accumulation steps more the memory will be saved but at
the cost of longer fine tuning time.

##  7 Further work

In this paper we show that LLMs are able to learn new information from limited
data with right LORA configurations. However the results have traces of
hallucinations. To mitigate hallucinations, within the current setting
different prompt templates have to be experimented. It also boils down to the
way dataset is prepared. Chunking techniques like semantic chunking provide a
way to create chunks that stand on their own as separate information entities.
This could be explored further as a dataset preparation recipe to reduce
hallucinations.

##  8 Conclusion

The paper discussed on the topic of fine tuning open source Large Language
Models with proprietary documents and code repositories. In the Dataset
preparation sections detailed steps on creating the dataset from raw documents
and code bases is given. It is followed by experiments with different methods
of preparation and manual evaluation of the model responses with different
LORA configurations. Finally some pointers observed during the fine tuning
process are given as guidelines.

## References

  * [1] Haoran Xu, Young Jin Kim, Amr Sharaf, and Hany Hassan Awadalla.  A paradigm shift in machine translation: Boosting translation performance of large language models, 2024.
  * [2] Tiannan Wang, Jiamin Chen, Qingrui Jia, Shuai Wang, Ruoyu Fang, Huilin Wang, Zhaowei Gao, Chunzhao Xie, Chuou Xu, Jihong Dai, Yibin Liu, Jialong Wu, Shengwei Ding, Long Li, Zhiwei Huang, Xinle Deng, Teng Yu, Gangan Ma, Han Xiao, Zixin Chen, Danjun Xiang, Yunxia Wang, Yuanyuan Zhu, Yi Xiao, Jing Wang, Yiru Wang, Siran Ding, Jiayang Huang, Jiayi Xu, Yilihamu Tayier, Zhenyu Hu, Yuan Gao, Chengfeng Zheng, Yueshu Ye, Yihang Li, Lei Wan, Xinyue Jiang, Yujie Wang, Siyu Cheng, Zhule Song, Xiangru Tang, Xiaohua Xu, Ningyu Zhang, Huajun Chen, Yuchen Eleanor Jiang, and Wangchunshu Zhou.  Weaver: Foundation models for creative writing, 2024.
  * [3] Zhonghua Zheng, Lizi Liao, Yang Deng, and Liqiang Nie.  Building emotional support chatbots in the era of llms, 2023.
  * [4] Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom.  Llama 2: Open foundation and fine-tuned chat models, 2023.
  * [5] Xiao-Yang Liu, Guoxuan Wang, Hongyang Yang, and Daochen Zha.  Fingpt: Democratizing internet-scale data for financial large language models, 2023.
  * [6] Chaoyi Wu, Weixiong Lin, Xiaoman Zhang, Ya Zhang, Yanfeng Wang, and Weidi Xie.  Pmc-llama: Towards building open-source language models for medicine, 2023.
  * [7] Rajvardhan Patil and Venkat Gudivada.  A review of current trends, techniques, and challenges in large language models (llms).  Applied Sciences, 14(5), 2024.
  * [8] Cheonsu Jeong.  A study on the implementation of generative ai services using an enterprise data-based llm application architecture.  Advances in Artificial Intelligence and Machine Learning, 03(04):1588–1618, 2023.
  * [9] Florin Cuconasu, Giovanni Trappolini, Federico Siciliano, Simone Filice, Cesare Campagnano, Yoelle Maarek, Nicola Tonellotto, and Fabrizio Silvestri.  The power of noise: Redefining retrieval for rag systems, 2024.
  * [10] Angels Balaguer, Vinamra Benara, Renato Luiz de Freitas Cunha, Roberto de M. Estevão Filho, Todd Hendry, Daniel Holstein, Jennifer Marsman, Nick Mecklenburg, Sara Malvar, Leonardo O. Nunes, Rafael Padilha, Morris Sharp, Bruno Silva, Swati Sharma, Vijay Aski, and Ranveer Chandra.  Rag vs fine-tuning: Pipelines, tradeoffs, and a case study on agriculture, 2024.
  * [11] Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen.  Lora: Low-rank adaptation of large language models, 2021.
  * [12] Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer.  Llm.int8(): 8-bit matrix multiplication for transformers at scale, 2022.
  * [13] Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer.  Qlora: Efficient finetuning of quantized llms.  In A. Oh, T. Neumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine, editors, Advances in Neural Information Processing Systems, volume 36, pages 10088–10115. Curran Associates, Inc., 2023.
  * [14] Mark Horowitz.  1.1 computing’s energy problem (and what we can do about it).  In 2014 IEEE International Solid-State Circuits Conference Digest of Technical Papers (ISSCC), pages 10–14, Feb 2014.
  * [15] Dhiraj Kalamkar, Dheevatsa Mudigere, Naveen Mellempudi, Dipankar Das, Kunal Banerjee, Sasikanth Avancha, Dharma Teja Vooturi, Nataraj Jammalamadaka, Jianyu Huang, Hector Yuen, Jiyan Yang, Jongsoo Park, Alexander Heinecke, Evangelos Georganas, Sudarshan Srinivasan, Abhisek Kundu, Misha Smelyanskiy, Bharat Kaul, and Pradeep Dubey.  A study of bfloat16 for deep learning training, 2019.
  * [16] Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko.  Quantization and training of neural networks for efficient integer-arithmetic-only inference, 2017.
  * [17] Memory Decreases! But Latency Increases…., howpublished = https://github.com/timdettmers/bitsandbytes/issues/6 .
  * [18] Shengyu Zhang, Linfeng Dong, Xiaoya Li, Sen Zhang, Xiaofei Sun, Shuhe Wang, Jiwei Li, Runyi Hu, Tianwei Zhang, Fei Wu, and Guoyin Wang.  Instruction tuning for large language models: A survey, 2023.
  * [19] Rapid Automatic Keyword Extraction algorithm domain independent keyword extraction algorithm which tries to determine key phrases in a body of text by analyzing the frequency of word appearance and its co-occurance with other words in the text.  https://pypi.org/project/rake-nltk/.
  * [20] Querying local documents, powered by LLM.  https://github.com/snexus/llm-search/blob/main/src/llmsearch/parsers/doc.py.
  * [21] Suriya Gunasekar, Yi Zhang, Jyoti Aneja, Caio César Teodoro Mendes, Allie Del Giorno, Sivakanth Gopi, Mojan Javaheripi, Piero Kauffmann, Gustavo de Rosa, Olli Saarikivi, Adil Salim, Shital Shah, Harkirat Singh Behl, Xin Wang, Sébastien Bubeck, Ronen Eldan, Adam Tauman Kalai, Yin Tat Lee, and Yuanzhi Li.  Textbooks are all you need, 2023.