Skip to content

Commit e7fecba

Browse files
authored
docs : update HOWTO‑add‑model.md for ModelBase and new model classes (ggml-org#14874)
This patch updates the example in docs/development/HOWTO-add-model.md to reflect recent changes after `TextModel` and `MmprojModel` were introduced. It replaces the outdated `Model` base class with `TextModel` or `MmprojModel` and updates the registration example accordingly. Signed-off-by: Wook Song <[email protected]>
1 parent e2b7621 commit e7fecba

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

docs/development/HOWTO-add-model.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ The convert script reads the model configuration, tokenizer, tensor names+data a
2323

2424
The required steps to implement for an HF model are:
2525

26-
1. Define the model `Model.register` annotation in a new `Model` subclass, example:
26+
1. Define the model `ModelBase.register` annotation in a new `TextModel` or `MmprojModel` subclass, example:
2727

2828
```python
29-
@Model.register("MyModelForCausalLM")
30-
class MyModel(Model):
29+
@ModelBase.register("MyModelForCausalLM")
30+
class MyModel(TextModel):
31+
model_arch = gguf.MODEL_ARCH.MYMODEL
32+
```
33+
34+
or
35+
36+
```python
37+
@ModelBase.register("MyModelForConditionalGeneration")
38+
class MyModel(MmprojModel):
3139
model_arch = gguf.MODEL_ARCH.MYMODEL
3240
```
3341

@@ -75,9 +83,10 @@ block_mappings_cfg: dict[MODEL_TENSOR, tuple[str, ...]] = {
7583
`transformer.blocks.{bid}.norm_1` will be mapped to `blk.{bid}.attn_norm` in GGUF.
7684

7785
Depending on the model configuration, tokenizer, code and tensors layout, you will have to override:
78-
- `Model#set_gguf_parameters`
79-
- `Model#set_vocab`
80-
- `Model#write_tensors`
86+
- `TextModel#set_gguf_parameters`
87+
- `MmprojModel#set_gguf_parameters`
88+
- `ModelBase#set_vocab`
89+
- `ModelBase#modify_tensors`
8190

8291
NOTE: Tensor names must end with `.weight` or `.bias` suffixes, that is the convention and several tools like `quantize` expect this to proceed the weights.
8392

0 commit comments

Comments
 (0)