Negative sampling (Mikolov et al., 2013) replaces the full softmax with a binary task: is this word a real context, or one of a few random words? Each training pair then costs only one positive and a handful of negative dot products.
Implement negative_sampling_loss(v_c, u_o, U_neg), the logistic loss for the true pair plus the sampled negatives.
logaddexp to compute -log sigma(x) stably.The positive term is -log sigma(u_o . v_c); each negative term is -log sigma(-u_n . v_c). Sum all of them.
No results yet
Run your code to check it against the examples, or submit to run every test.