BNS
Bayesian negative sampling is the theoretically optimal negative sampling algorithm that runs in linear time.
Install / Use
/learn @liubin06/BNSREADME
Bayesian Negative Sampling
Official implementation for the paper accepted at IEEE ICDE 2023.
📄 Citation
If you use this work in your research, please cite:
@inproceedings{Bin:ICDE:2023,
title={Bayesian Negative Sampling for Recommendation},
author={Liu Bin and Wang Bang},
booktitle={2023 IEEE 39th International Conference on Data Engineering (ICDE)},
year={2023},
pages={749-761},
doi={10.1109/ICDE55515.2023.00063}
}
🛠️ Installation
- numpy: For Matrix Factorization implementation (
main_MF.py) - pytorch: For LightGCN implementation (
main_lightGCN.py)
🎯 Algorithm Overview
The Bayesian Negative Sampling framework operates as follows:
1. Candidate Selection
Randomly select candidate set $\mathcal{M}_u$ from negative instances.
2. Prior Probability Computation
Assume $pop_l \sim B (N, P_{fn}(l))$, compute: $$P_{fn}(l) = \frac{pop_l}{N}$$ Time complexity: $\mathcal{O}(1)$
3. Likelihood Estimation
Compute empirical CDF: $F_{n}(\hat{x} _ l) = \frac{1}{n} \sum I_ {|x_ \cdot \leq \hat{x}_l |}$
Time complexity: $\mathcal{O}(|I|)$
📊 Theoretical Foundation: By the Glivenko Theorem (1933), $F_n(\cdot)$ uniformly converges to $F(\cdot)$, enabling probabilistic prediction of false negatives.
4. Posterior Calculation
Compute unbiased estimator: $\mathtt{unbias}(l) = \frac{[1 - F(\hat{x} _ l)] [1-P _ {fn} (l)] }{1 - F(\hat{x}_ l) -P_{fn}(l) + 2F(\hat{x}_ l)P_{fn}(l)}$
Time complexity: $\mathcal{O}(1)$
5. Bayesian Sampling
Select instance minimizing: $j = \mathop{\arg\min}\limits_{l \in\mathcal{M}_u}~ \mathtt{info}(l)\cdot [1-(1+\lambda)\mathtt{unbias}(l)]$
Time complexity: $\mathcal{O}(1)$
📊 Datasets
- MovieLens100K & MovieLens1M: GroupLens
- Yahoo!-R3: Yahoo Webscope
💡 Flexibility: BNS is dataset-agnostic. Simply replace
train.csvandtest.csvfiles, ensuring appropriate prior probability modeling.
📬 Contact
For questions, please contact:
- Bin Liu: binliu@swjtu.edu.cn
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
