Quadratic configuration interaction method including single and double substitutions has been used to optimize the possible structures of BeH2 and H2S molecules with the 6-311++g(3df,3pd) basis set. The results show that the ground state of BeH2 molecule is of D∞h symmetry and is in the X1Σ+g state, the ground state of H2S molecule is of C2v symmetry and in the X1A1 state. The equilibrium geometry, dissociation energy, harmonic frequencies and force constants have been calculated. The potential energy functions of BeH2 and H2S have been derived by using the many-body expansion theory. The potential energy functions describe correctly the configurations and the dissociation energies of the two ground-state molecules.