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:
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.