Skip to content

Get number of tokens of a prompt before sending to bedrock API - FM model: meta-llama3

0

Could you please help me to get the number of in the given prompt before sending it to bedrock invoke model through boto3. The foundation model is meta:llama3 70B Instruct.

asked a year ago737 views

2 Answers
0

I apologize, but I don't have specific information about getting the token count for the meta-llama3 70B Instruct model through Amazon Bedrock before sending the prompt.

However, I can provide some general guidance based on how token counting works with other models in Bedrock:

  1. Bedrock doesn't provide a built-in method to count tokens before sending a request.

  2. The exact tokenization method can vary between models, so an precise count would require using the same tokenizer as the specific model.

  3. For many models, you can get an approximate token count from the API response after invoking the model. The response often includes metadata about input and output token counts.

  4. If you need a precise count before sending, you may need to implement your own tokenizer that matches the one used by the meta-llama3 model, or use a third-party library designed for this purpose.

  5. As an alternative, you could send a test request with a small max_tokens limit and examine the response metadata to get the input token count, without generating a full response.

For the most accurate information, I recommend checking the latest Amazon Bedrock documentation or contacting AWS support for guidance specific to the meta-llama3 70B Instruct model.
Sources
Integrate foundation models into your code with Amazon Bedrock | AWS Machine Learning Blog
PromptModelInferenceConfiguration - Amazon Bedrock

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

0

Not in Bedrock. But here is an external tool : https://lunary.ai/llama3-tokenizer

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.