We discuss the energy transfer mechanism between rare-earth 4f-shells and III-V semiconductor hosts. For Yb-doped InP, we have proposed an excitation and relaxation model, which explains experimental results for the electronic and optical properties. The Yb 4f-shell is excited by a recombination of an electron and a hole at an electron trap formed by Yb, which is located near the bottom of the conduction band of InP. At high temperatures, the relaxation energy of the Yb 4f-shell is back transferred as a host electron-hole pair, resulting in Yb luminescence quenching. We have found that Er-doped GaAs samples grown by metalorganic chemical vapor deposition contain as much C as Er. Rutherford back scattering and electronic property measurement results suggested that most of the Er atoms form complexes with C atoms, and these complexes are not electrically active. Such samples showed complicated Er 4f-shell luminescence spectra. To obtain a simple Er luminescence spectrum with a high peak intensity, O was intentionally doped with Er. Er-O complexes seemed to be formed in GaAs and these are responsible for simple and strong 4f-shell luminescence.