huggingface / swift-chat

Mac app to demonstrate swift-transformers
Apache License 2.0
492 stars 37 forks source link

Support iOS devices #10

Closed ericlewis closed 12 months ago

ericlewis commented 1 year ago

Optimizes the UI for working across iPad / iPhone / macOS

ericlewis commented 1 year ago

I haven't tried to optimize for iOS yet, but it's cool to start working on iOS integration!

This PR looks great in terms of UI. However, it won't be possible to read the model file on iOS unless we use startAccessingSecurityScopedResource() on the file selected by the user in the file browser. Would you like to address that, or would you prefer that I submit it as a separate PR first?

Different PR would probably be a good idea. Works fine in simulator, never heard of security scoped resource on device 👁️

ericlewis commented 1 year ago

oh and I can address it if you like!

pcuenca commented 1 year ago

oh and I can address it if you like!

Amazing, thank you! Let me know if you need help.

ericlewis commented 1 year ago

@pcuenca I added the security scope handling in this PR simply because it was easy enough. The LLaMA 2 model is too big for my iPhone (apparently) and the distilgpt2 mlpackage uses token_scores which isn't supported by swift-transformers yet.. but it appears that the prediction does successfully go through on device.

pcuenca commented 1 year ago

distilgpt2 mlpackage uses token_scores which isn't supported by swift-transformers yet

Sorry about that, I'll upload a small compatible model later.

ericlewis commented 1 year ago

distilgpt2 mlpackage uses token_scores which isn't supported by swift-transformers yet

Sorry about that, I'll upload a small compatible model later.

modified swift-transformers to sort of support it, so no worries. rearranging UI after testing on device to feel more natural and will let you know when finished. changing to draft.

ericlewis commented 1 year ago

https://github.com/huggingface/swift-chat/assets/674503/6a8c4159-5d5f-4054-bf6c-141ce5f958a2

iPhone now defaults to a more compact interface as demonstrated above. iPad and macOS share the existing layout.

ericlewis commented 1 year ago

@pcuenca okie dokie, this should be good now! I have tested on iPad, iPhone, and macOS devices.