How to measure the contribution of each sample

Hi, I want to did some negative sampling.
It means that in a mini-batch of negative data samples, I wanto only samples part of them and used for training.
How to measure the contribution of each sample to the training in a batch ?
should I use

  1. the loss of each sample;
  2. the gradient of each sample

and how to get the gradient of each sample ?