# `Tiktokenex.Ranks`
[🔗](https://github.com/phiat/tiktokenex/blob/v0.1.0/lib/tiktokenex/ranks.ex#L1)

Loads and caches tiktoken rank files from priv/ranks/.

Rank files contain base64-encoded token bytes mapped to integer ranks.
Loaded ranks are cached in `:persistent_term` for fast repeated access.

# `inverse`

```elixir
@spec inverse(atom()) :: %{required(non_neg_integer()) =&gt; binary()}
```

Returns the inverse rank map (rank -> token bytes) for decoding.

Raises `ArgumentError` for unsupported encodings.

# `load`

```elixir
@spec load(atom()) :: %{required(binary()) =&gt; non_neg_integer()}
```

Returns the rank map for the given encoding.

The rank map is `%{binary() => non_neg_integer()}` where keys are raw
token bytes and values are their BPE merge ranks.

Results are cached in `:persistent_term` after first load.

Raises `ArgumentError` for unsupported encodings.

# `supported_encodings`

```elixir
@spec supported_encodings() :: [atom()]
```

Returns the list of supported encodings.

# `warmup`

```elixir
@spec warmup() :: :ok
```

Pre-loads rank maps for all supported encodings into persistent_term.

Call this at application startup to avoid first-call latency and
concurrent parsing races.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
