Live data from Hacker News

I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

apps.apple.com

111–120 of 208 posts

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#111

Earlier quoted context omitted.

you can absolutely access and continue all your past chats in cnvrs! would love to hear what you think: https://testflight.apple.com/join/ERFxInZg

My free / mostly open source app also stores conversation history, synced via iCloud https://ChatOnMac.com edit: I can't reply to you below: Do you have the right app, there's no TestFlight just App Store link - if it's ChatOnMac then it should have a dropdown at the top of the chat room to select a model. If it's empty or otherwise bugged out please let me know what you see in the top menu. It filters the available…

Hey I tried the TestFlight. What are the steps after a fresh download for hooking it up to model?

I saw you can spec an OpenAI key but presume it would take llama or something else.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#112
post #102
post #55

Earlier quoted context omitted.

So the system prompt is just part of the first prompt in a conversation? How is that different from not having a system prompt?

No, system prompts are surrounded by [INST] [/INST]

No, every user input is surrounded by those tags. Scroll down from that link you posted and read the next two example prompts.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#113
post #2

Does it save all conversations and let me revisit them later? I use MLC Chat to run Mistral 7B on my iPhone at the moment, but the lack of conversation history is a real nuisance: https://apps.apple.com/us/app/mlc-chat/id6448482937

[flagged]

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#114
post #105
post #2

Does it save all conversations and let me revisit them later? I use MLC Chat to run Mistral 7B on my iPhone at the moment, but the lack of conversation history is a real nuisance: https://apps.apple.com/us/app/mlc-chat/id6448482937

No. Source: bought the app.

Also, new chat blows away previous chat.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#115
post #2

Does it save all conversations and let me revisit them later? I use MLC Chat to run Mistral 7B on my iPhone at the moment, but the lack of conversation history is a real nuisance: https://apps.apple.com/us/app/mlc-chat/id6448482937

In your experience, how could these local LLMs become snappier than using streamed API calls? How far are they if not? How soon do you guess they’ll get there? I understand the motivation includes factors other than performance, I’m just curious about performance as it applies to UX.

Honestly I think being able to run any kind of LLM on a phone is a miracle. I'm astonished at how good (and how fast) Mistral 7B runs under MLC Chat on iOS, considering the constraints of the device.

I don't use it as more than a cool demo though, because the large hosted LLMs (I tend to mostly use GPT-4) are massively more powerful.

But... I'm still intrigued at the idea of a local, slow LLM on my phone enhanced with function calling capabilities, and maybe usable for RAG against private data.

The rate of improvement in these smaller models over the past 6 months has been incredible. We may well find useful applications for them even despite their weaknesses compared to GPT-4 etc.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#116

Earlier quoted context omitted.

TL;DR: No, nearly all these apps will use GPU (via Metal), or CPU, not Neural Engine (ANE). Why? I suggest a few main reasons: 1) No Neural Engine API 2) CoreML has challenges modeling LLMs efficiently right now. 3) Not Enough Benefit (For the Cost... Yet!) This is my best understanding based on my own work and research for a local LLM iOS app. Read on for more in-depth justifications of each point! --- 1) No Neural…

This is really interesting, thank you. What would be the downside to padding all inputs to have consistent input token size?

Conceptually, to the best of my understanding, nothing too serious; perhaps the inefficiency of processing a larger input than necessary?

Practically, a few things:

If you want to have your cake & eat it too, they recommend Enumerated Shapes[1] in their coremltools docs, where CoreML precompiles up to 128 (!) variants of input shapes, but again this is fairly limiting (1 tok, 2 tok, 3 tok... up to 128 token prompts.. maybe you enforce a minimum, say 80 tokens to account for a system prompt, so up to 200 tokens, but... still pretty short). But this is only compatible with CPU inference, so that reduces its appeal.

It seems like its current state was designed for text embedding models, where you normalize input length by chunking (often 128 or 256 tokens) and operate on the chunks — and indeed, that’s the only text-based CoreML model that Apple ships today, a Bert embedding model tuned for Q&A[2], not an LLM.

You could used a fixed input length that’s fairly large; I haven’t experimented with it once I grasped the memory requirements, but from what I gather from HuggingFace’s announcement blog post[3], it seems that is what they do with swift-transformers & their CoreML conversions, handling the details for you[4][5]. I haven’t carefully investigated the implementation, but I’m curious to learn more!

You can be sure that no one is more aware of all this than Apple — they published "Deploying Transformers on the Apple Neural Engine" in June 2022[6]. I look forward to seeing what they cook up for developers at WWDC this year!

---

[1] "Use `EnumeratedShapes` for best performance. During compilation the model can be optimized on the device for the finite set of input shapes. You can provide up to 128 different shapes." https://apple.github.io/coremltools/docs-guides/source/flexi...

[2] BertSQUAD.mlmodel (fp16) https://developer.apple.com/machine-learning/models/#text

[3] https://huggingface.co/blog/swift-coreml-llm#optimization

[4] `use_fixed_shapes` "Retrieve the max sequence length from the model configuration, or use a hardcoded value (currently 128). This can be subclassed to support custom lengths." https://github.com/huggingface/exporters/pull/37/files#diff-...

[5] `use_flexible_shapes` "When True, inputs are allowed to use sequence lengths of `1` up to `maxSequenceLength`. Unfortunately, this currently prevents the model from running on GPU or the Neural Engine. We default to `False`, but this can be overridden in custom configurations." https://github.com/huggingface/exporters/pull/37/files#diff-...

[6] https://machinelearning.apple.com/research/neural-engine-tra...

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#117

Earlier quoted context omitted.

Wow, thanks so much for taking the time to test it out and share such great feedback! Thrilled about all those developments! More model options as well as link-based GGUF downloads on the way. On the 7b models: I’m very sorry for the poor experience. I wouldn’t recommend 7b over Q2_K at the moment, unless you’re on a 16GB iPad (or an Apple Silicon Mac!). This needs to be much clearer, as you observed the consequences…

4-bit StableLM and 2-bit 7B models do seem to be working more consistently.

That’s great to hear. I’m sorry again about that poor experience, and please do reach out if you have any other feedback!

Britt

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#118

Earlier quoted context omitted.

Do not download this. I downloaded this on my 14 Pro and it completely locked up the system to the point where even the power button wouldn’t work. I couldn’t use my phone for about 10 minutes.

I’m very sorry about your experience. That’s definitely not what I was aiming for, and I can imagine that was a nasty surprise. Any hang like that is unacceptable, full stop. My understanding is Metal is currently causing hangs on devices when there is barely enough RAM to fit the model and prompt, but not quite enough to run. Will work on falling back to CPU to avoid this kind of experience much more aggressively th…

Thanks for the response. Unfortunately on my device the behavior makes it impossible to report a bug using a screenshot as requested in the app. I can give you more device info if you want to narrow down the cause.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#119

Earlier quoted context omitted.

I’m very sorry about your experience. That’s definitely not what I was aiming for, and I can imagine that was a nasty surprise. Any hang like that is unacceptable, full stop. My understanding is Metal is currently causing hangs on devices when there is barely enough RAM to fit the model and prompt, but not quite enough to run. Will work on falling back to CPU to avoid this kind of experience much more aggressively th…

Thanks for the response. Unfortunately on my device the behavior makes it impossible to report a bug using a screenshot as requested in the app. I can give you more device info if you want to narrow down the cause.

Yes of course, I would very much appreciate that, if you’d be so generous — thank you! You can email britt [at] bl3 [dot] dev

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#120

Earlier quoted context omitted.

What the hell are you on about? Apple has rules and guidelines on (user) generated content, GP was asking whether it applied here.

Understood but at some point it becomes the responsibility of the user of the hammer if they use it in an attack or hurt someone else or themselves with it. LLMs are LLMs anyone who is using it who doesn’t understand it is language model and is a machine and how at the high level it works, probably shouldn’t use it, and it shouldn’t be Apple’s responsibility to keep hammers out of the hands of everyone due to the few…

[deleted]
Post reply on HN