BetterTransformer is not supported for all models. Check this list to see if a model supports BetterTransformer.

Before you start, make sure you have 🤗 Optimum installed.
Enable BetterTransformer with the [PreTrainedModel.to_bettertransformer] method:

from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder")
model.to_bettertransformer()