How do you protect against zerg and marine rush or large groups as protoss?
My zealots and stalkers just get trounced. They are upgraded but still, mass marines just destroy me.
What can I do as Protoss?
The essence lies in how to handle "large groups", you need to look at the advantages you have:
Sentries: These early units allow you to split up or trap an army by using force fields, reduce incoming range damage using their Guardian Shield and allow you to create hallucinated units which will take damage aways from your real units.
Colossus: There mid game units are known for their AoE damage, they will quickly fry a bio ball. Watch out for air though, although Stalkers are useful against air to some extent... :-)
High Templar: These mid to late game unit is also known for their powerful storms, they also have Feedback to drain energy from units and can warp in more powerful Archons...
Carriers: These late games units have interceptors that work for them so they can stay at a safe distance and thus result in devastating damage if your enemy doesn't manage to take them, supported by an army it can be tricky for your opponent to handle you.
Check the macro of one of your replays that is related to your question, you might be able to find an economy or production gap that makes it clear why you got outnumbered. Check if you expanded well (at 2 workers / min patch), check if you resources were too high (not enough gateways), and so on...
As you are asking about rushes, I would say that (in addition to obvious things like good macro and fundamentals):
As direct face-to-face technique, positioning. They have many more units than you, and you should exploit this by leading them into chokes, funneling them into tight spots etc, and using force fields. The goal is to let ALL of your units shooting while only a few of their units can.
Otherwise, scouting (ok this is a generic one but very important). The easiest is if you see an early spawning pool from zerg. If you know beforehand that your opponent is going for a ling / marine rush, set up defenses. Wall off your ramp and put a zealot on "hold position", with stalkers in back, and a sentry to forcefield and keep half their units at the bottom of the ramp. In the case of a zealot rush, this is completely solid, there is nothing they can do.
If that doesn't defend against it, then your fundamental mechanics just need improvement.
Later in the game marines can still pose a huge threat, and by this time you should move up to higher tier units like colossus.
Remember to keep every single unit alive, as even a zealot costs twice as much as a marine. Even if your micro skills are crap (like mine), it's easy to just select a zealot whose shields are out, and run him to the back of your army. If they were focus-firing him, their army will move (thus not attacking). If they were not focusing, then at least he can live to recharge his shields and fight again.