Sentence Similarity
Model2Vec
English
embeddings
static-embeddings
feature-extraction
quantization
1-bit
littlebit
Instructions to use MisasAI/LittlePotion-1BPW with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Model2Vec
How to use MisasAI/LittlePotion-1BPW with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("MisasAI/LittlePotion-1BPW") embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) print(embeddings.shape) - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -27,6 +27,25 @@ Want it even smaller? See [LittleLittlePotion-164kb](https://huggingface.co/Misa
|
|
| 27 |
|
| 28 |
*This is an unofficial version and all credit goes to MinishLab for the original.*
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
## What's in here
|
| 31 |
|
| 32 |
| File | What it is |
|
|
@@ -54,22 +73,6 @@ print(vecs @ vecs.T) # higher = more similar
|
|
| 54 |
|
| 55 |
You need `torch`, `safetensors` and `tokenizers`. If `model2vec` is installed you get a normal `StaticModel` back, otherwise a small stand-in with the same `encode()`.
|
| 56 |
|
| 57 |
-
## How it works
|
| 58 |
-
|
| 59 |
-
potion is basically one big table, one row of numbers per word piece. LittleBit rewrites that table as two much smaller tables made only of +1 and -1 (one bit each), plus a few scaling numbers. Squashing it like that breaks it at first, so it's retrained afterwards (on Wikipedia text, matching the similarities between sentences) until it gives nearly the same answers as the original.
|
| 60 |
-
|
| 61 |
-
## How good is it?
|
| 62 |
-
|
| 63 |
-
| | Size | STS-B | SICK-R | SciFact |
|
| 64 |
-
|---|---|---|---|---|
|
| 65 |
-
| original potion-base-8M | 15 MB | 0.754 | 0.647 | 0.505 |
|
| 66 |
-
| LittlePotion-1BPW | 931 KB | 0.737 | 0.625 | 0.453 |
|
| 67 |
-
| kept | 16x smaller | 98% | 97% | 90% |
|
| 68 |
-
|
| 69 |
-
STS-B and SICK-R test "are these two sentences about the same thing?" (Spearman). SciFact tests search (nDCG@10). Search drops more because it was only retrained for similarity.
|
| 70 |
-
|
| 71 |
-
If you don't need it this small, normal 4-bit potion (about 4 MB) is basically lossless and simpler. LittlePotion is for when every kilobyte counts.
|
| 72 |
-
|
| 73 |
## Check it yourself
|
| 74 |
|
| 75 |
```
|
|
|
|
| 27 |
|
| 28 |
*This is an unofficial version and all credit goes to MinishLab for the original.*
|
| 29 |
|
| 30 |
+
## 1BPW is impossible
|
| 31 |
+
|
| 32 |
+
Nope, JPEG manages similar compression. And actually the method is very similar to JPEG compression.
|
| 33 |
+
|
| 34 |
+
How it works: potion is basically one big table, one row of numbers per word piece. LittleBit rewrites that table as two much smaller tables made only of +1 and -1 (one bit each), plus a few scaling numbers. Squashing it like that breaks it at first, so it's retrained afterwards (on Wikipedia text, matching the similarities between sentences) until it gives nearly the same answers as the original.
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## How good is it?
|
| 38 |
+
|
| 39 |
+
| | Size | STS-B | SICK-R | SciFact |
|
| 40 |
+
|---|---|---|---|---|
|
| 41 |
+
| original potion-base-8M | 15 MB | 0.754 | 0.647 | 0.505 |
|
| 42 |
+
| LittlePotion-1BPW | 931 KB | 0.737 | 0.625 | 0.453 |
|
| 43 |
+
| kept | 16x smaller | 98% | 97% | 90% |
|
| 44 |
+
|
| 45 |
+
STS-B and SICK-R test "are these two sentences about the same thing?" (Spearman). SciFact tests search (nDCG@10). Search drops more because it was only retrained for similarity.
|
| 46 |
+
|
| 47 |
+
If you don't need it this small, normal 4-bit potion (about 4 MB) is basically lossless and simpler. This is just an interesting proof of concept model.
|
| 48 |
+
|
| 49 |
## What's in here
|
| 50 |
|
| 51 |
| File | What it is |
|
|
|
|
| 73 |
|
| 74 |
You need `torch`, `safetensors` and `tokenizers`. If `model2vec` is installed you get a normal `StaticModel` back, otherwise a small stand-in with the same `encode()`.
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
## Check it yourself
|
| 77 |
|
| 78 |
```
|