In principle, ants in compost are not a problem, they do not harm the rotting and eventually fly out on their own. However, ants only feel comfortable in compost that is too dry, i.e. that the compost obviously does not contain enough moisture. Compost should feel like a sponge that has been squeezed out. If the compost is too dry, you should pour in a large can of water once (or more if the compost is larger) and mix the compost well.
You can use the mature compost with ants for the following reason: ants are not direct pests in the garden. They occasionally cause damage by stirring up small seedlings from the soil, which can then dry up. The greater damage they cause indirectly, by nurturing the aphids, also root aphids. You can often see ants defending “their” aphids from ladybugs, lacewings and other animals that want to eat them.
One extra tip: ants don’t like many odors. Pour a liquid with a strong odor into the nests. This can be a cheap perfume, but cedar oil or eucalyptus oil (pharmacy or drugstore) works better. You only need to apply these strong scented oils drop by drop, and the ants will flee. Of course, you must continue to monitor the spots and repeat the scent treatment as soon as new ant colonies appear. But if you are consistent, the ants will move away without you having to wield the “chemical mace”.
So, strong odors and more moisture, and you’ll be rid of your little pests.