add num_tokens param and use it in the template