The Köln–Jülich Lamb-shift polarimeter is used to measure the nuclear polarization of the hydrogen or deuterium beam produced with the atomic-beam source for the polarized target at the ANKE spectrometer at COSY-Jülich. The precision of the earlier results had been dominated by the recombination of atoms in the ionizer. Protons or deuterons from the dissociative ionization of unpolarized recombined H2 or D2 molecules had strongly contributed to the extracted ion beam. To suppress this effect, in the new ionizer a nonevaporable getter pump of about 2000l∕s H2 or D2 pumping speed surrounds the ionization volume. It reduces the extracted current of unpolarized ions, produced from the recombined molecular gas, by a factor of about 20 compared with the earlier value, which reduces the error of the polarization measurements to about 0.5%. Now the H2 or D2 molecules in the ionization volume predominantly are those which are contained in the incoming beam from the atomic beam source. This allows the measurement of the fraction of unpolarized molecules in the polarized atomic H⃗ or D⃗ beam. The improvement achieved is a valuable step toward the measurement of the nuclear polarization of a gas sample, extracted from the storage cell of the polarized internal gas target for the spectrometer ANKE in the COSY-Jülich storage ring with the Lamb-shift polarimeter. Furthermore, the results show that the polarization of proton or deuteron beams would be increased by the installation of such a pump around the ionization volume of atomic-beam ion sources with an electron-impact ionizer. For ECR ionizers the recombined H2 or D2 molecules would be absorbed, whereas the noble gases, used as buffer, are not pumped by the getter material.