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!
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.