NIR spectroscopy works by shining near-infrared light on a sample and measuring the amount of light that is absorbed or reflected. The absorption of NIR light causes molecular vibrations, and different chemical bonds will absorb light at specific wavelengths. By analyzing these absorption patterns, one can determine the molecular composition of the sample.