Instructions to use litert-community/GLiClass-Edge-v3.0-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/GLiClass-Edge-v3.0-LiteRT with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
GLiClass-Edge v3.0 for LiteRT: S128 and S256 graphs (fp32 and fp16 weights), float16 token table, tokenizer, Python host, Android sample, conversion scripts, fixtures and card
88c9095 verified Download conversion/device_rows.py from litert-community/GLiClass-Edge-v3.0-LiteRT: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/litert-community/GLiClass-Edge-v3.0-LiteRT/resolve/main/conversion/device_rows.py
- Command line
-
hf download hf://litert-community/GLiClass-Edge-v3.0-LiteRT/conversion/device_rows.py
-
curl -L -o device_rows.py https://huggingface.co/litert-community/GLiClass-Edge-v3.0-LiteRT/resolve/main/conversion/device_rows.py
1.96 kB
| """Round 2 A4: S26 gate rows (shape of the openjev run's device_rows.py) -> fixtures/device_rows_s128.json (every | |
| oracle row that fits S128, 482) and fixtures/device_rows_s256.json (every row, 552), file order. | |
| One row = {id, ids, label_positions, n_labels, logits}: the oracle's own token ids (so the device run measures the | |
| graph, not a tokenizer), the <<LABEL>> token positions (routing row k = one-hot at label_positions[k]), and the | |
| official fp32 logits for the n_labels real slots (reference). Top level = {seq, slots, rows, ..., rows_data}. | |
| """ | |
| import json | |
| from common import LABEL_SLOTS, ROOT, dump_json | |
| def main(): | |
| oracle = json.loads((ROOT / "fixtures/oracle.json").read_text())["records"] | |
| for seq in (128, 256): | |
| out = ROOT / f"fixtures/device_rows_s{seq}.json" | |
| assert not out.exists(), f"never overwrite {out.name}" | |
| keep = [r for r in oracle if r["fits"][f"s{seq}"]] | |
| rows = [] | |
| for r in keep: | |
| assert r["n_tokens"] <= seq and r["n_labels"] <= LABEL_SLOTS and len(r["label_positions"]) == r["n_labels"] | |
| assert len(r["logits"]) == r["n_labels"] and max(r["label_positions"]) < r["n_tokens"] | |
| rows.append(dict(id=r["id"], ids=r["input_ids"], label_positions=r["label_positions"], n_labels=r["n_labels"], | |
| logits=r["logits"])) | |
| by_source = {} | |
| for r in keep: | |
| by_source[r["source"]] = by_source.get(r["source"], 0) + 1 | |
| record = dict(seq=seq, slots=LABEL_SLOTS, rows=len(rows), by_source=by_source, | |
| boundary_rows_top1_lt_0_9=sum(r["top1_softmax"] < 0.9 for r in keep), | |
| reference="official gliclass 0.1.20 pipeline logits, CPU fp32 (fixtures/oracle.json)", | |
| rows_data=rows) | |
| dump_json(f"fixtures/device_rows_s{seq}.json", record) | |
| print({k: v for k, v in record.items() if k != "rows_data"}) | |
| if __name__ == "__main__": | |
| main() | |