The principle of vaccination is based on the property of ‘memory’ of immune system.
In vaccination, a preparation of antigenic proteins or inactivated/live but weakened pathogen is introduced into the body.
The antigens generate primary immune response by producing antibodies along with memory B-cells and T-cells. When the vaccinated person is attacked by the same pathogens, the existing memory B-cells and T-cells recognise the antigen and overwhelm the invaders with massive production of lymphocytes and antibodies. Hepatitis-B vaccine is produced from yeast.