Base trim before carpet?
The type of carpet can affect the height of the baseboards.
I usually set the gap at 3/8” this is normally sufficient but some really thick carpets need a full 1/2”.
When I say thick I am talking like heavy weave like Berber where the backing is heavy and the weave is thicker than 3/8 but most carpets will fit fine with 3/8”.