Instructions to use QLNI/SHADOW-250M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Shadow
How to use QLNI/SHADOW-250M with Shadow:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download benchmarks/embedding_bench.py from QLNI/SHADOW-250M: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/QLNI/SHADOW-250M/resolve/main/benchmarks/embedding_bench.py
- Command line
-
hf download hf://QLNI/SHADOW-250M/benchmarks/embedding_bench.py
-
curl -L -o embedding_bench.py https://huggingface.co/QLNI/SHADOW-250M/resolve/main/benchmarks/embedding_bench.py
1.45 kB
| """Benchmark the frozen binary vocabulary on word similarity (WordSim-353). | |
| Every token has a fixed 512-bit code. If the codes carry meaning, similar words should | |
| have nearby codes. This script scores each human-rated word pair by Hamming similarity | |
| between the two words' codes and reports the Spearman correlation with the human ratings. | |
| Random codes score about 0. Runs offline on the files in this repo. | |
| python benchmarks/embedding_bench.py | |
| """ | |
| import csv, pathlib, sys | |
| import numpy as np | |
| HERE = pathlib.Path(__file__).resolve().parent; ROOT = HERE.parent | |
| sys.path.insert(0, str(ROOT)) | |
| from shadow_runtime.retriever import enc | |
| fp = np.unpackbits(np.load(ROOT / "fp131072.npy"), axis=1)[:, :512] | |
| rows = [l.split(",") for l in open(HERE / "wordsim353.csv", encoding="utf-8").read().splitlines() if l] | |
| rng = np.random.default_rng(0); rand = rng.integers(0, 2, size=fp.shape).astype(np.uint8) | |
| def score(table): | |
| xs, ys = [], [] | |
| for w1, w2, human in rows: | |
| i1, i2 = enc(" " + w1.lower()), enc(" " + w2.lower()) | |
| if len(i1) != 1 or len(i2) != 1: continue | |
| xs.append(1 - np.mean(table[i1[0]] != table[i2[0]])); ys.append(float(human)) | |
| from scipy.stats import spearmanr | |
| return spearmanr(xs, ys).statistic, len(xs) | |
| r, n = score(fp); r0, _ = score(rand) | |
| print(f"WordSim-353, single-token pairs (n={n})") | |
| print(f" frozen vocabulary codes : Spearman {r:.3f}") | |
| print(f" random codes (baseline) : Spearman {r0:.3f}") | |