We present observations and models of the behaviour of the HI and HeI lines between 1.6 and 2.2um in a small sample of compact HII regions. As in our previous papers on planetary nebulae, we find that the `pure 1.7007um 4^3D-3^3P and 2.16475um 7^(3,1)G-4^(3,1)F HeI recombination lines behave approximately as expected as the effective temperature of the central exciting star(s) increases. However, the 2.058um 2^1P-2^1S HeI line does not behave as the model predicts, or as seen in planetary nebulae. Both models and planetary nebulae showed a decrease in the HeI 2^1P-2^1S/HI Br gamma ratio above an effective temperature of 40000K. The compact HII regions do not show any such decrease. The problem with this line ratio is probably due to the fact that the photoionisation model does not account correctly for the high densities seen in these HII regions, and that we are therefore seeing more collisional excitation of the 2^1P level than the model predicts. It may also reflect some deeper problem in the assumed model stellar atmospheres. In any event, although the normal HeI recombination lines can be used to place constraints on the temperature of the hottest star present, the HeI 2^1P-2^1S/HI Br gamma ratio should not be used for this purpose in either Galactic HII regions or in starburst galaxies, and conclusions from previous work using this ratio should be regarded with extreme caution. We also show that the combination of the near infrared `pure recombination line ratios with mid-infrared forbidden line data provides a good discriminant of the form of the far ultraviolet spectral energy distribution of the exciting star(s). From this we conclude that CoStar models are a poor match to the available data for our sources, though the more recent WM-basic models are a better fit.