Some breeds have been specifically nurtured to herd animals. But those same breeds might try to even herd humans if given the chance.
Even if that specific dog was never used to herd farm animals, the instinct is still in their DNA, so you need to teach them not to try to herd people by nipping at their ankles. Because, while herding is completely normal, unwanted herding can cause a lot of nerves, and even anger.
The first thing you need to know is that you shouldn’t react by running or yelling when a dog starts attacking your ankles. If you do that, the dog will think they are just playing a game, or performing a duty. Second, you need to learn how you can prevent and manage this behavior. Finally, you need to allow them to herd or simulate herding in controlled environments.
You can even try playing tug-of-war with them. That will probably quench their thirst. The more your dog exercises, the less energy he will have to go around trying to herd you and your friends. When it comes to training, there are a few methods you can try. One thing you can do is put your dog on a leash whenever you invite people around. You also need to teach them patience.
For example, don’t give them a treat unless they can stay still for 20 seconds. You will probably also need to work on your dog’s attention span, making them focus on you instead of on moving objects. And, if nothing seems to work, you can hire a professional to help you out.