I don't think you can deduce it out of somewhere... you take your local symmetries and create invariant objects under those symmetry transformations. The thing is that nothing (at least only by that principle) to write down many terms or insert different things. But if you write down some representations you'll have:
(3 , 1,1) : a triplet under SU(3) alone, and SU(2) singlet . Here you can have right handed quarks, since they don't see the weak sector
(3, 2, 1) : a triplet under SU(3), a doublet under SU(2). Here you can have left handed quarks , which can interact under both strong and weak interactions.
(8, 1, 1) : the gauge bosons of SU(3)
(1, 3,1 ) : the gauge bosons of SU(2)
(1,1,1) : Here you can have the right handed fermions.
(1, 2, 1) :colorless SU(2) doublets... here you can have the Higgs or the left handed leptons.
The last 1 in the parenthesis could as well be changed...it's in fact the hypercharge of the particle (but because this can change from particle to particle I just wrote 1)
in a notations [SU(3) , SU(2), U(1)]... I don't know if I forgot anything...
Also for the SU(3) triplets you must have in mind that 3 could as well be \bar{3} (the complex repr). For SU(2) that's not the case, since 2 \equiv \bar{2}.
One example to get an idea of a term, is to write down a mass term for the leptons... In that case you need something like : m \bar{\psi}_L \bar{\psi}_R which means you need to mix the left and right handed leptons... going to the above scheme you have to make an invariant object with:
(1,2,Y_1) and (1,1,Y_2). The result of those two would be (1,2,Y_1) \otimes (1,1,Y_2) = (1,2,Y_1+Y_2)
In order to make an invariant object with those two, you need an extra SU(2) doublet (because a 2\otimes 2=3 \oplus 1 contains the singlet) and with hypercharge -Y_1 -Y_2 - and that's the role for the Higgs... As a result you obtain the lepton Yuawa terms.
The result of those three combinations would have to be (1,1,0)