# `Transmuter.Repo`
[🔗](https://github.com/georgeguimaraes/transmuter/blob/v2.0.0/lib/transmuter/repo.ex#L1)

A model repository: its configuration files and its ONNX files in each variant.

Hugging Face ONNX exports keep each component (`model`, `encoder_model`, `decoder_model_merged`, ...) in `onnx/`, in variants that differ by a suffix: `model.onnx` is fp32, `model_q4.onnx` has 4-bit weights, and so on. `load!/2` reads the configuration of the repository, and `component_file/3` picks the file of a component.

The variant of a component comes from, in this order:

  1. the `:variant` option, an atom such as `:q4` or a map from component names to atoms
  2. the `dtype` of the `transformers.js_config` block in `config.json`, a string or a map
  3. the default that the task gives, when the repository has that file
  4. fp32, then the other variants in the order of `@variants`

A repository has two chat templates. `:chat_template` is that of the tokenizer: `chat_template.jinja`, else the template of `tokenizer_config.json`, else that of the processor. `:processor_chat_template` is that of the processor of a multimodal model, as `ProcessorMixin` of Python transformers 4.57 loads it: the template of `chat_template.json`, else `chat_template.jinja`, else the `"chat_template"` of `processor_config.json`.

# `component_file`

Returns the path in the repository of the ONNX file of `component` (for example `"model"` or `"decoder_model_merged"`), in the variant that the rules of this module pick. `default` is the variant of the task.

# `image_token_id`

Returns the id of the image token of a vision language model from `config.json`, or `nil`.

The id is `image_token_id`, or else `image_token_index`, its other name in the `attribute_map` of `Mistral3Config` and `LlavaConfig` of Python transformers.

# `load!`

Reads the configuration files of `source` (`{:hf, repo}` or a local directory).

A Hub source reads its file list from the Hub again, or from the cache when the Hub cannot be reached.

Options: `:variant` and the options of `Transmuter.Hub`.

# `load_component!`

Loads the ONNX file of `component` with `Transmuter.load!/2`. `opts` go to `Transmuter.load!/2`.

# `sentence_transformers`

Returns the first result of `read` that is not `nil`, on the source of `repo` and then on the base model in its model card. `read` takes a source and reads the sentence-transformers files of that source, such as `modules.json`. ONNX exports often leave these files out, and their base model has them.

When the Hub denies the base model, such as a gated model without a token or a model that does not exist, this function logs a warning and does not read it.

# `special_token`

Returns the special token `name` (such as `"pad"` or `"eos"`) as a string, or `nil`.

The token comes from `special_tokens_map.json`, then `tokenizer_config.json`, then the `"extra_special_tokens"` map of `tokenizer_config.json`, as in Python transformers. A token in these files is a string or a map with `"content"`.

# `variants`

Returns the variants that the repository has for `component`.

---

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