Download tests/test_core.py from Angshul/Bayesian_LangChain: direct link, hf CLI and curl.
- Browser
- Download file 930 Bytes
-
https://huggingface.co/Angshul/Bayesian_LangChain/resolve/main/tests/test_core.py
- Command line
-
hf download hf://Angshul/Bayesian_LangChain/tests/test_core.py
-
curl -L -o test_core.py https://huggingface.co/Angshul/Bayesian_LangChain/resolve/main/tests/test_core.py
930 Bytes
| import math | |
| from bayesian_langchain.core import BayesianIndex, DocumentRecord | |
| from bayesian_langchain.smc import normalize_logweights | |
| def test_all_negative_infinity_weights_become_uniform(): | |
| p = normalize_logweights([float('-inf'), float('-inf'), float('-inf')]) | |
| assert p == [1/3, 1/3, 1/3] | |
| def test_authoritative_current_document_beats_stale_high_overlap(): | |
| docs = [ | |
| DocumentRecord('stale','The current HR portal is WorkSphere.','Current HR portal','cache',{'reliability_alpha':6,'reliability_beta':6,'authority':0.45,'freshness':0.18}), | |
| DocumentRecord('official','Leave requests and payslips are now handled in PeopleHub.','Migration complete','official',{'reliability_alpha':18,'reliability_beta':2,'authority':0.98,'freshness':1.0}), | |
| ] | |
| hits = BayesianIndex(docs).search('What is the current HR portal for leave requests and payslips?', k=2) | |
| assert hits[0].document.id == 'official' | |