Instructions to use ZibinDong/ActionCodec2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZibinDong/ActionCodec2 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ZibinDong/ActionCodec2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download runtime/backends/actioncodec2/packing.py from ZibinDong/ActionCodec2: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/ZibinDong/ActionCodec2/resolve/main/runtime/backends/actioncodec2/packing.py
- Command line
-
hf download hf://ZibinDong/ActionCodec2/runtime/backends/actioncodec2/packing.py
-
curl -L -o packing.py https://huggingface.co/ZibinDong/ActionCodec2/resolve/main/runtime/backends/actioncodec2/packing.py
1.51 kB
| """Runtime opt-in controls for lossless fixed-vocabulary Set-BPE search.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| class EncodingSearch: | |
| 'Independent post-encoding stages; defaults retain ranked merge replay.' | |
| spatial_search: bool = False | |
| temporal_search: bool = False | |
| search_window: int = 32 | |
| search_beam: int = 4 | |
| def __post_init__(self): | |
| for name in ("spatial_search", "temporal_search"): | |
| if not isinstance(getattr(self, name), bool): | |
| raise TypeError(f"{name} must be a bool") | |
| for name in ("search_window", "search_beam"): | |
| value = getattr(self, name) | |
| if isinstance(value, bool) or not isinstance(value, int) or value < 1: | |
| raise ValueError(f"{name} must be a positive integer") | |
| if self.search_beam > 64: | |
| raise ValueError("search_beam must be at most 64") | |
| def enabled(self): | |
| return self.spatial_search or self.temporal_search | |
| def validate_codec(self, scheme, bins): | |
| if not self.enabled: | |
| return | |
| if scheme != "set_bpe": | |
| raise ValueError("packing search requires set_bpe") | |
| if len(bins) > 8 or max(bins) > 255: | |
| raise ValueError("packing search supports at most eight slots and 255 bins per slot") | |
| if self.search_window * len(bins) > 256: | |
| raise ValueError("search_window times profile width must be at most 256") | |