There are a few methods, but a combination multi step system is best. Call an owner operated carpet cleaner with a good reputation and a big truckmount steam cleaner.
FYI
DRY CLEANING is a misnomer as it is not dry, it simply does not use steam. Once upon a time solvents were used but now dry cleaning simply refers to basically spray and wipe system. This will not flush out dirt.
STEAM CLEANING is a misnomer as it is actually Hot Water, rather than pure steam (steam vapour is emitted as a result). When a powerful truckmount system is used, the dirt is flushed out from deep in the carpet with pressurised very hot water and vacuumed back out with strong vacuum. This is best for nearly all situations that are heavily soiled. Only woven wool carpet may shrink with HWE, but these are rare as hens teeth and shrinking therefore is not even a consideration any longer with modern (20years) carpets.
ENCAPSULATION is a method where encapsulating detergents are scrubbed into the carpet to release the dirt, allowed to dry and crystalise around the dirt particles, then subsequently vacuumed out once dry (Although the carpet appears clean instantly). This is often used before steam cleaning as a chemical of choice due to it's remoavle residue qualities, or after steam cleaning to provide a more thorough clean.
For very badly soiled carpets, the following gives a good system to restore it.
1. The carpet should be inspected to determine fibre type and construction to determine appropriate chemical and method.
2. Thorough Vacuumed to remove dry soil.
3. Presprayed with a detergent to suit the carpet fibre and allowed dwell time. (wool is sensitive to highly alkaline detergents and it's pH level should be restored after cleaning, nylon, polypropylene, etc are more durable...)
4. The carpet is then Pre scrubbed with a rotary or orbital (buffing type) machine with a suitable pad to physically agitate the dirt from the fibres.
5. Then the carpet is rinsed/cleaned using steam Hot Water Extraction from a powerful petrol powered truck mounted (not portable) machine. Truck mount machines often have 10x the power that can be obtained from an electrical powerpoint which a portable relies on.
6. Sometimes a cotton pad on the rotary or orbital machine is used to wipe remaing dirt and dry carpet.
6. Acid rinse for wool carpets or where there is a possibility of 'browning' (lignin from the carpet backing rising to the surface).
7. The carpet is often groomed using a rake, and air mover fans are employed.