AsciiMAster's picture
Initial release: 14352 OFF categories with bge-m3 embeddings
2fb8a62 verified
|
Raw History Blame Contribute Delete
4.17 kB
---
license: odbl
language:
- en
- de
- fr
- pl
pretty_name: Open Food Facts Categories with bge-m3 Embeddings
size_categories:
- 10K<n<100K
task_categories:
- feature-extraction
- sentence-similarity
tags:
- open-food-facts
- food
- taxonomy
- embeddings
- bge-m3
- multilingual
- pgvector
configs:
- config_name: default
data_files: off-categories-bge-m3.parquet
---
# Open Food Facts Categories with bge-m3 Embeddings
A flat, embedded version of the [Open Food Facts](https://world.openfoodfacts.org/data)
category taxonomy. Each row is one OFF category with multilingual display
names, its full ancestor path, and a 1024-dimensional embedding produced by
[`BAAI/bge-m3`](https://huggingface.co/BAAI/bge-m3).
The intent is to let downstream projects do retrieval over OFF categories
without having to re-fetch `categories.json`, walk the parent graph, or run
the embedding model.
## Source project
Generated by [BetterCategories / offcat](https://github.com/AsciiMAster/BetterCategories),
a small Go service that does natural-language food category search backed by
this exact table.
## Schema
| Column | Type | Notes |
|-----------------|---------------------|--------------------------------------------------------------------|
| `id` | string | OFF category id, e.g. `en:apple-juices`. Primary key. |
| `name_en` | string (nullable) | English display name. |
| `name_pl` | string (nullable) | Polish display name. |
| `name_de` | string (nullable) | German display name. |
| `name_fr` | string (nullable) | French display name. |
| `parents` | list<string> | Direct parent category ids. |
| `ancestor_path` | string (nullable) | Pre-computed flattened ancestor chain used as embedding context. |
| `context_hash` | string (nullable) | SHA-256 of the text fed to the embedding model. Useful for diffs. |
| `embedding` | list<float32>[1024] | `bge-m3` embedding of `name_en + " > " + ancestor_path` (cosine). |
Row count: 14352.
## Embedding details
- Model: `BAAI/bge-m3` (served via an OpenAI-compatible local API in the
upstream project; any deployment of the same model produces compatible
vectors).
- Dimension: 1024.
- Distance: cosine similarity is the intended metric.
- Input text: the English category name concatenated with `" > "` and the
flattened ancestor path. See `taxonomy.go` in the source project for the
exact `embedTextFor` formatting.
## Quick start
```python
import pyarrow.parquet as pq
import numpy as np
table = pq.read_table("off-categories-bge-m3.parquet")
df = table.to_pandas()
mat = np.stack(df["embedding"].to_numpy()) # (14352, 1024)
mat /= np.linalg.norm(mat, axis=1, keepdims=True)
# encode a query with bge-m3, normalise, then:
# scores = mat @ query_vec
```
For Postgres users, the same data is what `BetterCategories` writes into a
`pgvector` `vector(1024)` column with an HNSW cosine-ops index.
## Licence and attribution
This dataset is a derivative database of Open Food Facts and is therefore
distributed under the **Open Database License (ODbL) v1.0**, the same
licence as the upstream taxonomy.
- Upstream data: Open Food Facts, https://world.openfoodfacts.org/data,
ODbL-1.0.
- Modifications applied: parent graph flattened into an `ancestor_path`
string per category; `bge-m3` embeddings computed over the concatenation
of the English name and that ancestor path; rows with no embedding are
excluded.
If you redistribute this dataset or a derivative of it (including dumps,
indexes, or further-trained models that incorporate the data), you must:
1. Keep the resulting database under ODbL-1.0.
2. Credit Open Food Facts contributors.
3. Note that the data has been modified.
The Go source code that produced this dataset is licensed under MIT and is
not covered by ODbL.