The issue is that I'm using dotenv to pass in the max_length value. os.environ.get returns a str not an int, regardless of what's in the .env file. I just needed to cast it to an int instead
hf_max_length = int(os.environ.get('HF_MAX_LENGTH', 512))