View example on GitHub
Set up your model
Start by importing the necessary libraries:model/model.py
model/model.py
Define the model class
Create aModel class that loads Mistral-7B and its tokenizer when the server starts:
model/model.py
Implement inference
Thepredict function handles inference by tokenizing input, generating text, and decoding the output.
model/model.py
Configure your deployment
Define dependencies
Specify the necessary Python packages inconfig.yaml:
config.yaml
Allocate compute resources
Mistral-7B requires an NVIDIA A10G GPU for efficient inference:config.yaml
Deploy the model
Install the Baseten CLI and sign in:Install the Baseten CLIFor other platforms or a specific version, see the Baseten CLI install reference.
- macOS or Linux
- Windows
Terminal
Sign in
config.yaml, push your model to Baseten:
Model: line (abc1d2ef in the example). The first deploy takes several minutes while Baseten builds the image and the model loads its weights from Hugging Face.
Once the deployment is active, call the model with the Baseten CLI:
call_model.py
abc1d2ef with your model ID.
To use the Truss CLI instead, sign in with truss login, deploy with truss push, and call the model with truss predict --published -d '{"prompt": "What is a large language model?"}'.