HG stands for hyperglide, which all modern shimano cassettes use. The numerical part of the HG-labeled cassettes will tell you roughly where they stand; for road groups, sora is 3xxx series, tiagra 4xxx, 105 is 5xxx, etc. In the mountain world, they have it a bit different, with plain deore at 5xxx, slx at 6xxx, xt at 7xxx, saint at 8xxx, and xtr at 9xxx. Things don't run congruently on the road and mountain lines; the saint and xtr are no "better" than the dura-zce stuff. They just used to have, like, a million different mtb groups. The second number is typically indicative of a generation; 6600 is the last gen ultegra. The current generation is 6700,When they redesign it from the ground up again, it'll most likely be 6800. Numbers after the second will typically indicate options; ultegra cranks came in fc-6600 (double), fc-6650 (compact double), and 6603 (triple) flavors, for instance. Sometimes, the "50" can be a mid-generation tweak, when they fixed the goofy cassettes and freehub bodies in the dura-ace.
Cassettes marketed as HG-50 are likely to be non-series stuff, oem pull-offs or overstocks, or non-current new stock. These days, the alphanumerics for cassettes tends to be stuff like cs-6700. You can figure that a road hg-50 will be roughly equivalent to 105, but that's sort of arguable. In the end, most of the shimano stuff is compat, assuming the number of speeds match between cassette, shifters, and r.derailer, and that your r.derailer is equipped to tackle the largest cassette cog and the total chainwrap. So, if you're grabbing a cassette for your roadbike, make sure you're getting a 9speed cassette, with no larger than a 28t rear cog. Don't sweaT the label too much; no one will care if you don't.
-rob