Proposal: Develop a Token Estimation Tool for Foundation Models

Dear Apple Foundation Models Development Team,

I am a developer integrating Apple Foundation Models (AFM) into my app and encountered the exceededContextWindowSize error when exceeding the 4096-token limit.

Proposal:
I suggest Apple develop a tool to estimate the token count of a prompt before sending it to the model. This tool could be integrated into FoundationModels Framework for ease of use.

Benefits:
A token estimation tool would help developers manage the context window limit and optimize performance. I hope Apple considers this proposal soon.

Thank you!

Answered by DTS Engineer in 854992022

Thanks for sharing the feedback report.

Just to add a bit more color here based on my conversation with the team: "it is very hard to know for a meaningful estimate outside the context of a concrete use case," and so app developers can probably consider developing "their own heuristics for estimating token count in the context of their own use case, with the model they’re going to use."

Another bit is that you can use Instruments.app to know the token count in your use case, as discussed here.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

It is best to submit these through https://feedbackassistant.apple.com

Dear Apple Foundation Models Development Team

This isn't the Foundation Models Development Team. These forums aren't a direct link for consumers worldwide to directly contact employees at Apple.

These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding.

These forums are not where Apple's actual developers chat about new features.

If you have a suggestion, you should raise it at: https://feedbackassistant.apple.com/

Thanks you

Hi @thuongvp,

As others have mentioned, you can file an enhancement request with Feedback Assistant. And once you've done so, please share the FB number here so we can track it.

Best,

-J

Yes, I’ve submitted it. Here’s my FB number: FB19724539.

Thanks for sharing the feedback report.

Just to add a bit more color here based on my conversation with the team: "it is very hard to know for a meaningful estimate outside the context of a concrete use case," and so app developers can probably consider developing "their own heuristics for estimating token count in the context of their own use case, with the model they’re going to use."

Another bit is that you can use Instruments.app to know the token count in your use case, as discussed here.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Proposal: Develop a Token Estimation Tool for Foundation Models
 
 
Q