Update README.md
Browse files
README.md
CHANGED
|
@@ -2,4 +2,128 @@
|
|
| 2 |
license: other
|
| 3 |
license_name: link-attribution
|
| 4 |
license_link: https://dejan.ai/link-attribution/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: other
|
| 3 |
license_name: link-attribution
|
| 4 |
license_link: https://dejan.ai/link-attribution/
|
| 5 |
+
pretty_name: 200k Wikidata Embeddings (Gemini)
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- wikidata
|
| 10 |
+
- embeddings
|
| 11 |
+
- semantic-search
|
| 12 |
+
- entity-linking
|
| 13 |
+
- gemini
|
| 14 |
+
task_categories:
|
| 15 |
+
- feature-extraction
|
| 16 |
+
- sentence-similarity
|
| 17 |
+
size_categories:
|
| 18 |
+
- 100K<n<1M
|
| 19 |
+
# license: choose one before publishing (see "Licensing" below)
|
| 20 |
+
configs:
|
| 21 |
+
- config_name: default
|
| 22 |
+
data_files:
|
| 23 |
+
- split: train
|
| 24 |
+
path: gemini_norm.parquet
|
| 25 |
+
dataset_info:
|
| 26 |
+
features:
|
| 27 |
+
- name: entity_id
|
| 28 |
+
dtype: string
|
| 29 |
+
- name: label
|
| 30 |
+
dtype: string
|
| 31 |
+
- name: embedding
|
| 32 |
+
sequence: float32
|
| 33 |
+
length: 768
|
| 34 |
+
splits:
|
| 35 |
+
- name: train
|
| 36 |
+
num_examples: 199998
|
| 37 |
+
config_name: default
|
| 38 |
---
|
| 39 |
+
|
| 40 |
+
# 200k Wikidata Embeddings (Gemini)
|
| 41 |
+
|
| 42 |
+
Text embeddings for ~200,000 Wikidata entities, generated from each entity's
|
| 43 |
+
English label with Google's **`gemini-embedding-001`** model. Vectors are
|
| 44 |
+
768-dimensional and **L2-normalized to unit length**, so cosine similarity
|
| 45 |
+
equals a plain dot product.
|
| 46 |
+
|
| 47 |
+
## What's inside
|
| 48 |
+
|
| 49 |
+
| Column | Type | Description |
|
| 50 |
+
|---|---|---|
|
| 51 |
+
| `entity_id` | `string` | Wikidata Q-identifier, e.g. `Q42` |
|
| 52 |
+
| `label` | `string` | English label, e.g. `Douglas Adams` |
|
| 53 |
+
| `embedding` | `list<float32>[768]` | Unit-length embedding of the label |
|
| 54 |
+
|
| 55 |
+
- **Rows:** 199,998
|
| 56 |
+
- **Dimensions:** 768
|
| 57 |
+
- **Normalization:** L2 (every vector has norm 1.0)
|
| 58 |
+
- **Source model:** `gemini-embedding-001` (native 3072-dim, requested at
|
| 59 |
+
`output_dimensionality=768`, then L2-normalized)
|
| 60 |
+
- **File:** `gemini_norm.parquet`
|
| 61 |
+
|
| 62 |
+
The entities are a sample of the full Wikidata label set (~118.7M labelled
|
| 63 |
+
entities). Only the label string was embedded — no descriptions, aliases, or
|
| 64 |
+
statements were used.
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from datasets import load_dataset
|
| 70 |
+
|
| 71 |
+
ds = load_dataset("dejanseo/200k-wiki-data-embeddings-gemini", split="train")
|
| 72 |
+
print(ds[0]["entity_id"], ds[0]["label"])
|
| 73 |
+
print(len(ds[0]["embedding"])) # 768
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
Semantic search with cosine similarity (a dot product, since vectors are
|
| 77 |
+
unit-length):
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
import numpy as np
|
| 81 |
+
|
| 82 |
+
emb = np.array(ds["embedding"], dtype=np.float32) # (199998, 768)
|
| 83 |
+
ids = ds["entity_id"]
|
| 84 |
+
labels = ds["label"]
|
| 85 |
+
|
| 86 |
+
def nearest(query_vec, k=10):
|
| 87 |
+
scores = emb @ np.asarray(query_vec, dtype=np.float32) # cosine similarity
|
| 88 |
+
top = np.argsort(-scores)[:k]
|
| 89 |
+
return [(ids[i], labels[i], float(scores[i])) for i in top]
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## How it was built
|
| 93 |
+
|
| 94 |
+
1. English labels were pulled from a local Wikidata label database.
|
| 95 |
+
2. Each label was embedded via the Gemini Batch Embeddings API
|
| 96 |
+
(`gemini-embedding-001`, `output_dimensionality=768`).
|
| 97 |
+
3. The returned vectors were **L2-normalized** to unit length and written to
|
| 98 |
+
Parquet.
|
| 99 |
+
|
| 100 |
+
Because the vectors are truncated Matryoshka outputs (768 of the model's native
|
| 101 |
+
3072 dims) and then renormalized, they are directly usable for cosine /
|
| 102 |
+
dot-product retrieval.
|
| 103 |
+
|
| 104 |
+
## Companion dataset
|
| 105 |
+
|
| 106 |
+
A parallel set of embeddings for the **same 199,998 entities** was produced with
|
| 107 |
+
the open `google/embeddinggemma-300m` model (also 768-dim, unit-length). Because
|
| 108 |
+
the `entity_id` keys are identical, the two sets can be joined row-for-row for
|
| 109 |
+
cross-model comparison.
|
| 110 |
+
|
| 111 |
+
> Note on cross-model use: the two models place entities in differently-oriented
|
| 112 |
+
> spaces. Do **not** compare a Gemini vector directly against a Gemma vector —
|
| 113 |
+
> raw cross-model similarity is meaningless. Within a single model, similarity is
|
| 114 |
+
> well-behaved.
|
| 115 |
+
|
| 116 |
+
## Licensing
|
| 117 |
+
|
| 118 |
+
Wikidata labels are released under **CC0**. The embedding vectors are derived
|
| 119 |
+
outputs of Google's Gemini API and are subject to Google's applicable terms.
|
| 120 |
+
Choose and set a `license:` value in the metadata above that reflects how you
|
| 121 |
+
intend to distribute the derived vectors before publishing.
|
| 122 |
+
|
| 123 |
+
## Citation
|
| 124 |
+
|
| 125 |
+
If you use this dataset, please cite the source model and Wikidata:
|
| 126 |
+
|
| 127 |
+
- Google, `gemini-embedding-001`
|
| 128 |
+
- Wikidata (Wikimedia Foundation)
|
| 129 |
+
|