In most cases if your composting process is always a moist, hot active aerobic pile, the frequent weekly movements in the pile, and hot temperatures, will run the ant pests out of your pile. Once the compost is mature and homogeneous, usually they will move on anyway.
A little dry molasses, citrus oil, or mild natural soapy water mixtures (used in moderation and small amounts of course), are other safe natural, biodegradable ways to rid the pests out of the compost, without poisoning the biomass of organic matter.
Since ants are really beneficial, you really don't have to do anything but wait, and let them go away eventually on your own, while your compost breaks downs and cooks.
The entire Kingdom of God can be totally explained as an Organic Garden (Mark 4:26)