Catalyzes the NAD(P)H-dependent reduction of 4-hydroxyphenylpyruvate to 4-hydroxyphenyllactate and 3,4-dihydroxyphenylpyruvate to 3,4-dihydroxyphenyllactate in the biosynthesis of rosmarinic acid. Rosmarinic acid is an ester of caffeic acid and 3,4-dihydroxyphenyllactic acid. NADP is the preferred substrate. (2R)-2-hydroxy-3-(4-hydroxyphenyl)propanoate + NAD(+) = 3-(4-hydroxyphenyl)pyruvate + H(+) + NADH (2R)-2-hydroxy-3-(4-hydroxyphenyl)propanoate + NADP(+) = 3-(4-hydroxyphenyl)pyruvate + H(+) + NADPH (2R)-3-(3,4-dihydroxyphenyl)lactate + NADP(+) = 3-(3,4-dihydroxyphenyl)pyruvate + H(+) + NADPH (2R)-3-(3,4-dihydroxyphenyl)lactate + NAD(+) = 3-(3,4-dihydroxyphenyl)pyruvate + H(+) + NADH Belongs to the D-isomer specific 2-hydroxyacid dehydrogenase family.