Gauge invariance dictates the form of
the lagrangian of Electroweak theory, see e.g.[1]}, [2]}.
Let us consider a family of two leptons \( (\nu ,e)\)  (neutrino and electron) and two quarks \((u,d)\)  (up and down):
\(\psi ^\pm _{i,c,x}\)  are the spinor fields of the i-th particle (\(i=\nu ,e,u,d\) ), \(c\)  the color index
\(c=(r,g,b)\)  for \(i=(u,d)\)  and \(c=0\)  for \(i=(\nu ,e)\) ,
\(\gamma _\mu ,\gamma _5\) , \(\mu =0,1,2,3\)  are gamma matrices
and \(\psi ^\pm _{i,c,x}=(\psi _{i,c,L,x},\psi _{i,c,R,x})\)  with
\(\psi ^\pm _{i,c,s, x}\) , \(s=L,R\)  the chiral fields.
The classical electroweak lagrangian is chosen requiring the invariance under the local
\(U(1)_Y\) 
transformation (\(Y_{i,s}\)  are the hypercharges, \(g^{\prime }\)  the coupling)
\(\psi ^\pm _{i,c,s, x}\rightarrow e^{\pm i g^{\prime } Y_{i,s}\alpha _x}\psi ^\pm _{i,c,s, x}\) 
