There are many reasons why a carpet may yellow over time, but nicotine stains are one cause that is particularly nasty because of the smell. Nicotine also creates a very greasy type of stain. You can usually remove nicotine stains from carpet with a homemade cleaning solution, but if the stains are very deep and set-in, a professional cleaning may be in order. You might want to consider shampooing or steam cleaning the entire carpet after removing the stains to get it as fresh as possible.
Mix a solution of 1 qt. warm water, 1/2 tsp. liquid detergent, and 1 tbsp. white vinegar.
Dip a sponge into the solution and blot the area of carpet with the nicotine stain until some of it comes out onto the sponge.
Blot with a clean, dry towel or rags.
Repeat the process until you have removed as much of the stain as possible.
Blot the area with clean water.