  In this paper we develop a general method to obtain the Berry phase of
time-dependent Hamiltonians with a linear structure given in terms of the
$SU(1,1)$ and $SU(2)$ groups. This method is based on the similarity
transformations of the displacement operator performed to the generators of
each group, and let us diagonalize these Hamiltonians. Then, we introduce a
trilinear form of the Tavis-Cummings model to compute the $SU(1,1)$ and $SU(2)$
Berry phases of this model.
