Most effective means of removing coffee stains from carpet
Oxidise it using a mild oxidizing agent like $\ce{H2O2}$ (hydrogen peroxide). When it undergoes oxidation coloured compounds get decolorized. Good luck on cleaning it.