Build and deploy your first model
Help for setting up a clean development environment
>=3.8,<3.13
. To set up a fresh development environment,
you can use the following commands, creating a environment named truss_env
using pyenv
:.bashrc
:
truss init
command.
hello-world
with the following files:
config.yaml
- A configuration file for your model.model/model.py
- A Python file that contains your model codepackages/
- A folder to hold any dependencies your model needsdata/
- A folder to hold any data your model needsconfig.yaml
file and the model.py
file.
config.yaml
config.yaml
file is used to configure dependencies, resources, and
other settings for your model.
Let’s take a look at the contents:
requirements
: This is a list of pip
packages that will be installed when
your model is deployed.resources
: This is where you can specify the resources your model will use.secrets
: This is where you can specify any secrets your model will need, such as
HuggingFace API keys.config.yaml
file.
model.py
model.py
file.
__init__
: This is the constructor.load
: This is called at model startup, and should include any setup logic, such as weight downloading or initializationpredict
: This is the method that is called during inference.truss push
command.
transformers
library to load a pre-trained model,
from HuggingFace, and use it to classify the given text.
config.yaml
config.yaml
file.
model.py
model.py
file to use the transformers
library to load the model,
and then use it to predict the sentiment of a given text.
truss push