--- license: odbl language: - en - de - fr - pl pretty_name: Open Food Facts Categories with bge-m3 Embeddings size_categories: - 10K | 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[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.