12th Gen - Alder Lake (Golden Cove P-cores and Gracemont E-cores, max 8+8)
13th and 14th Gen - Raptor Lake (Raptor Cove P-cores and Gracemont E-cores, max 8+16)
13th and 14th Gen processors are completely identical and there are no changes whatsoever at the hardware level between them. Parts branded 14th Gen tend to have more aggressive clocks out of the box. The 14900KS is the exact same processor as the original 13900K, SKUs above the 13900K only increase in grade, being more aggressive with clock speeds and power consumption at each turn. 13900KS and 14900K are effectively identical, the 13900KS is a bit better silicon, 14900K is a bit more aggressive (+100MHz) on the clocks out of the box. A 13900K will pretty much never reach the clock speeds afforded by a 14900KS, though, unless it's a top 1% golden sample, so it's good to keep that in mind.
Regarding the P-cores, Raptor Cove is about the same thing as Golden Cove but with enlarged cache slices. Exception made to locked Core i5 segment (i5-K should be latest architecture for the generation) and below, most of them are still Alder Lake designs with the Golden Cove cores despite being branded Raptor Lake and code named that - they are not Raptor processors.
Heavily prefer a 14th Gen processor if possible, 13th Gen is still acceptable if you can shift an SKU up, eg. i9-13900K is preferred over i7-14700K, or i7-13700K is preferred over i9-12900K at the same price.
KS processors have the highest potential as they're the best silicon on average for each respective generation, a i9-12900KS and a i7-13700K, the 13700K should be marginally better, though the 12900KS should be a better behaved chip. Pick whatever's cheapest or whatever fancies you best.