Model Development Guide
Developers need to first create a folder named after the model in the models directory. Following that, add a new model by following the steps below:
Add Tokenizer or Processor
- Add tokenization_XXX.hpp or processing_XXX.hpp in the “models/XXX” folder.
- Build XXXTokenizer/Processor.
Example as follows:
Add Configuration
- Add configuration_XXX.hpp in the “models/XXX” folder.
- Build XXXNameConfig and XXXConfig.
Example as follows:
Note: The “name” parameter in “XXXNameConfig” is used to identify the operation in the model. It must be unique and should match the corresponding name in the original PyTorch/SafeTensor model that has not been converted.
For example, you can inspect the names of operations in a “.pth” model using the following code:
The output will be as follows:
The above code will print the part before “.weight” in the “key” values of all operations in the model.
This part should match the “name” parameter in the MLLM code. For instance, if the key is "layers.0.attention.wq.weight"
, the corresponding “name” parameter in MLLM should be "layers.0.attention.wq"
.
Add Model
- Add modeling_XXX.hpp in the “models/XXX” folder.
- Build XXXModel.
For example with LLaMA:
Use Model
Create a new file demo_XXX.cpp in the example directory.
For example with LLaMA: