egrace479's picture
Add text embeddings named for associated model (#21)
94bbc0b
|
Raw
History Blame Contribute Delete
4.29 kB
# Text Embeddings
Be sure to select the proper text embedding files for the model and dataset versions:
## BioCLIP 2
### Files
```
txt_emb_bioclip-2.json
txt_emb_bioclip-2.npy
txt_emb_species.json and txt_emb_species.npy: duplicates of txt_emb_bioclip-2 files to support pybioclip backwards compatibility
```
### Generation
[BioCLIP 2 text embeddings of TreeOfLife-200M](txt_emb_bioclip-2.npy) were generated with [`make_txt_embedding.py`](https://github.com/Imageomics/TreeOfLife-toolbox/blob/main/processing/scripts/make_txt_embedding.py), using the [`txt_emb_bioclip-2.json`](txt_emb_bioclip-2.json) to provide the 7-rank Linnean taxonomic names. These text embeddings match to the BioCLIP 2 training dataset, specified by the [catalog parquet from Revision a8f38b4](https://huggingface.co/datasets/imageomics/TreeOfLife-200M/blob/a8f38b4388579862c56ae57d6f094c2ac0e92e12/dataset/catalog.parquet). Note that [`txt_emb_species.npy`](txt_emb_species.npy) and [`txt_emb_species.json`](txt_emb_species.json) are duplicates of the BioCLIP 2 files, included here to maintain [pybioclip](http://github.com/Imageomics/pybioclip) functionality for versions 2.1.x and earlier.
## BioCLIP 2.5 Huge
### Files
```
txt_emb_bioclip-2.5-vith14.json
txt_emb_bioclip-2.5-vith14.npy
```
### Generation
The [BioCLIP 2.5 Huge text embeddings of TreeOfLife-200M](txt_emb_bioclip-2.5-vith14.npy) were also generated with [`make_txt_embedding.py`](https://github.com/Imageomics/TreeOfLife-toolbox/blob/main/processing/scripts/make_txt_embedding.py), but using the [`txt_emb_bioclip-2.5-vith14.json`](txt_emb_bioclip-2.5-vith14.json) to provide the 7-rank Linnean taxonomic names. These text embeddings match to the BioCLIP 2.5 Huge training dataset, specified by the catalog parquet added in [commit 97e2340](https://huggingface.co/datasets/imageomics/TreeOfLife-200M/commit/97e2340877d3a2ccad78078431fa68f404ed4870).
## Taxonomic JSON Construction
The `JSON` files were created from the [TreeOfLife-200M catalog](../catalog.parquet) (if reproducing the process, be sure to use the correct revision for the intended model) and [`VernacularName.tsv` component of the GBIF Backbone Taxonomy](https://doi.org/10.15468/39omei) using [`make_txt_embedding_json.py`](https://github.com/Imageomics/TreeOfLife-toolbox/blob/main/processing/scripts/make_txt_embedding_json.py) through the following process:
* **Null Value Filtering:** Remove records where `kingdom` or `species` are `null`.
* **Deduplication:** Rows are deduplicated based on the combination of `kingdom`, `phylum`, `class`, `order`, `family`, `genus`, and `species`. This ensures that each unique taxonomic combination appears exactly once.
* **Common Name Handling:** Currently, the catalog metadata often contains multiple common names for a single unique taxonomic combination. During processing, **the first English common name encountered** for a given unique taxonomic combination is retained. If English is not available, the first option of any language is used. We plan future improvements to establish a definitive 1-to-1 mapping or a more comprehensive common name strategy.
* **Corrupted Label Removal:** Records where any rank looks like a CSV-parsing leak, specifically an ISO-8601 timestamp `(^\d{4}-\d{2}-\d{2}T\d{2}:\d{2})` or the literal strings `true` / `false`, are removed. This was only necessary for the BioCLIP 2.5 Huge JSON.
### Structure
The JSON file is a single top-level array. Each element within this array is itself an array of two elements:
* **Inner Array (Index 0):** A list of strings representing the full taxonomic path from `kingdom` to `species`.
* **String (Index 1):** The common name associated with that taxonomic combination.
#### Example
```json
[
[
[
"Plantae",
"Bryophyta",
"Bryopsida",
"Bryales",
"Bryaceae",
"Bryum",
"gracile"
],
""
],
[
[
"Animalia",
"Chordata",
"Aves",
"Passeriformes",
"Mitrospingidae",
"Orthogonys",
"chloricterus"
],
"Olive-green tanager"
],
[
[
"Animalia",
"Arthropoda",
"Insecta",
"Lepidoptera",
"Lycaenidae",
"Orthomiella",
"rantaizana"
],
"Chinese Straight-wing Blue"
],
]
```