Skip to main content

View example on GitHub

This guide walks through deploying Mistral-7B, a powerful large language model (LLM), using Truss. You’ll configure the model, set up inference, allocate resources, and deploy it as an API endpoint.

Set up your model

Start by importing the necessary libraries:
model/model.py
Specify the Hugging Face model checkpoint:
model/model.py

Define the model class

Create a Model class that loads Mistral-7B and its tokenizer when the server starts:
model/model.py

Implement inference

The predict 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 in config.yaml:
config.yaml

Allocate compute resources

Mistral-7B requires an NVIDIA A10G GPU for efficient inference:
config.yaml

Deploy the model

Push your Truss to Baseten:
Once deployed, call the model using the Truss CLI:
Or send a request to the API endpoint:

Check for optimized engine support

For optimized performance we have open-source and Baseten optimized engines, such as Baseten’s TensorRT-LLM, Baseten-Embeddings-Inference, vLLM and SGLang.