COSY works by correlating the chemical shifts of different nuclei that are scalar-coupled to each other. The technique provides a 2D spectrum where the axes represent the chemical shifts of two different nuclei. Cross-peaks in the 2D spectrum indicate coupling between these nuclei, thus providing insights into the molecular structure.