The process likely involves pyrolysis, a generic term for the thermal degradation pathways of organic compounds.
In the case of carbohydrates, like glucose (shown below), the most common function groups are alcohols (R-OH). Alcohols undergo dehydration in the presence of strong acids, but the reaction can also be promoted by extreme heat in the absence of oxygen. The presence of oxygen leads to combustion (bad!).
In a dehydration elimination reaction, the OH on one carbon and the H on a neighboring carbon leave to form water. This usually follows an E1-like mechanism, involving a carbocation intermediate. In the geochemical version, the necessary acid could come from nearby slightly acidic mineral.
Protonation of the alcohol:
$$\ce{(CH3)2CH-OH + H+ -> (CH3)2CH-OH2+}$$
Loss of leaving group:
$$\ce{(CH3)2-CH-OH2+ -> (CH3)2CH+ + H2O}$$
Loss of proton (regeneration of acid):
$$\ce{CH3-CH+-CH2-{\bf{H}} -> CH3-CH=CH2 + {\bf{H+}}}$$
Overall:
$$\ce{(CH3)2CH-OH ->[\ce{H+}][\Delta] CH3-CH=CH2 + H2O }$$
In the case of carbohydrates, they tend to dehydrate to carbonyl compounds, which can then decompose further into hydrocarbons by reductive and radical pathways.
For example, fructose is converted into furan derivatives, like 5-hydroxymethylfurfural, by a series of dehydrations and rearrangements:
$$\ce{C6H12O6 ->[\ce{H+}][\Delta] C6H6O3 + 3H2O}$$
The image above was created by Wikipedia user V8rik and released under the GNU Free Documentation License and the Creative Commons Attribution-Share Alike 3.0 Unported License.