Legato: How to Play Hammer-Ons and Pull-Offs Fast and Clean
A single hammer-on or pull-off (see [[hammer-on-pull-off-guitar:the article on hammer-ons and pull-offs]]) is the foundation. A legato passage is a chain of four to six such transitions in a row, and it has its own problems a single move doesn't have.
Volume drops toward the end of the chain - that's ordinary physics
Each hammer-on sounds a bit quieter than the one before it, because the string is already vibrating with less amplitude after the first pick strike - that's not a technique flaw, it's string physics. The fix isn't to hit the first note harder, it's to compensate with a sharper strike on each following finger, keeping the energy up through the chain.
The anchor finger doesn't lift early
In a long chain it's easy to unconsciously lift a finger off the fret slightly early while preparing for the next note - the string loses contact and the sound drops out for a split second. Each finger needs to stay pressed down right up to the moment of the next transition, not before.
Drill: a chain on one string, to a metronome
Take four notes from one pentatonic position on one string (see the article on getting started improvising) and play them as one continuous legato run - a single pick strike on the first note, hammer-ons and pull-offs only after that. Count to a metronome so the transitions land exactly on the beats, not just 'wherever it happens to land'.
Crossing strings inside a legato passage
When the chain moves to a neighboring string, it usually needs a fresh, light pick strike (legato rarely works across a string change without one) - drill exactly that moment on its own, since it's physically different from transitions within one string and most often the one that sounds least clean.
Speed is a result of cleanliness, not the other way around
Same principle as any other technique (see the article on speed and cleanliness): a legato passage that's unstable at a slow tempo doesn't become more stable at a fast one. Get every note sounding even and equally loud at a comfortable speed before raising the metronome.
Try it in practice
Open the metronome