# Deploy LLaVA with llama.cpp: Real-Time Multimodal AI on Mobile

> Learn how to deploy the LLaVA multimodal LLM with llama.cpp for real-time mobile visual understanding and instruction generation. This guide covers server setup, model download, Flask frontend/backend integration, and mobile access, highlighting how multimodal AI disrupts traditional development workflows.

- Source: https://www.waytoagi.com/en/kb/learning-path/multimodal-llm-real-world-manual
- Original (Feishu, Chinese): https://waytoagi.feishu.cn/wiki/XOucwqHrmiNlf5kK01xc61Vsnef
- Updated: 2026-11-10

---

The Model Adds a User Manual to the Real World

> Author: bluishfish 深度觉醒 2024-01-26 02:47 Posted in Shanghai
>
> Author's WeChat account: https://mp.weixin.qq.com/s/08S3XFO2Np6oHXaKxOyDDg
>
> The code is open-sourced, so anyone with hands-on skills can deploy it themselves — it's worth a try
>
> https://github.com/bluishfish/llavaprompt

I deployed llava on my phone; I'll write up the specific implementation steps later. The application prospects for LVM are enormous, custom prompts are the future, and I'm aiming to get it deployed in the car before traveling for the Spring Festival.
> 🎬 This is a Feishu video, [view it in the Feishu knowledge base](https://waytoagi.feishu.cn/wiki/XOucwqHrmiNlf5kK01xc61Vsnef)

Using the server approach takes 9 seconds, and the fastest it can be sped up to is only 1.5 seconds. In theory, using voice-interaction prompts to analyze the scenery along the way and instantly capture dynamic hot spots should be good enough for now.

To reach millisecond latency, on-device inference on mobile is the way to go. Phones with large memory and high computing power are about to take off — the pressure on chips is huge.

![](https://www.waytoagi.com/api/kb-media/QaeVbQFK4oDSJkxeqt0cJo2ZnHe)

The specific tutorial follows.


# **Based on a Multimodal LLM (Adding a User Manual to the Real World)**


## **Introduction**

With the booming development of ChatGPT(), large models are profoundly affecting every industry, and the rapid pace of technological progress makes it feel as if "a day is as long as a year" (the number of new technologies emerging each day even exceeds that of the past year). In this fast-moving tide, multimodal technology, as the industry's frontier, is advancing by leaps and bounds, showing the momentum to unify computer vision (CV) and natural language processing (NLP).

This article introduces an application that can quickly explain the real world: based on a multimodal LLM, it provides a real-time user manual for the real world. Place your phone where the car's camera would be, and the app can analyze in real time the latest trends in your current area this Spring Festival. It not only demonstrates the power of multimodal technology but also offers us a deeper explanation of the real world.

![](https://www.waytoagi.com/api/kb-media/ISzGb0JsioQcnmx5VPocnGcOnwU)

This is one of the quick ways to use multimodal technology on a phone — **"a close-up feel of the crushing blow that large models deliver to traditional APP development."**

In this architecture, the backend uses llama.cpp to host the LLaVA model, providing inference services for the application. Meanwhile, a Flask app is deployed for data pre-processing and post-processing, providing a Stream streaming service. The frontend page uses HTML5 to capture images and user input, with a design that prioritizes simplicity and efficiency.


## **Setting Up the llama.cpp Server**

![](https://www.waytoagi.com/api/kb-media/MSxWbaAxiopORCxLQGzcIBk3nKc)

```
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
mkdir build
cd build
cmake .. -DLLAMA_CUBLAS=ON # Remove the flag if CUDA is unavailable
cmake --build . --config Release
```

![](https://www.waytoagi.com/api/kb-media/ICg8b7TVeolYQbxILSmcZQssn1e)


## **LLaVA Model**

Download the model ggml_llava-v1.5-13b; here we choose the 13b 4bit model.

```
wget https://huggingface.co/mys/ggml_llava-v1.5-13b/resolve/main/mmproj-model-f16.gguf
wget https://huggingface.co/mys/ggml_llava-v1.5-13b/resolve/main/ggml-model-q4_k.gguf
```

![](https://www.waytoagi.com/api/kb-media/RUEZbpWJzorgI5x7tjFcvO58n7e)

BakLLaVA offers faster inference, but its support for Chinese is weaker, and 7b models are generally lacking in semantic understanding, especially in scenarios that require standardized data formats for interaction. Function calls and action operations depend heavily on the model's AGI capabilities. I hope the open-source community keeps pushing forward and catches up with GPT-4V's level soon.


## **Running the Inference Service**

Deploy the model with llama.cpp, where -ngl specifies 35 layers placed on the GPU for inference, and -ts 100,0 concentrates all workloads on a single card.

```cpp
./bin/server -m ggml-model-q4_k.gguf --mmproj mmproj-model-f16.gguf -ngl 35 -ts 100,0 # For GPU-only, single GPU

# ./bin/server -m ggml-model-q4_k.gguf --mmproj mmproj-model-f16.gguf # For CPU
```

![](https://www.waytoagi.com/api/kb-media/HadubDxiEo9WcXx9V4schgc2nYe)

On a machine with an RTX 3090, VRAM usage is approximately 9GB, and it takes about 5–9 seconds to infer one image.

![](https://www.waytoagi.com/api/kb-media/C17zbEzdZo4UGRxRkymcygrnnjd)

For more parameters, please refer to:

```
https://github.com/ggerganov/llama.cpp/blob/master/examples/server/README.md
```


## **Preparing the LLaVA Prompt**

### **Setting Up the Virtual Environment**

```
git clone https://github.com/bluishfish/llavaprompt.git
cd llavaprompt
pip install -r requirements.txt
```

### **Generating SSL Certificate**

When providing services using the Stream method, HTTPS protocol is required. Therefore, an SSL certificate must be generated first. For developer mode, we use a simple self-signed certificate without binding a domain name. Please ignore the browser security warning when accessing.

```
openssl req -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out cert.pem -keyout key.pem
flask run --host=0.0.0.0 --key key.pem --cert cert.pem --debug --port 5002
```

![](https://www.waytoagi.com/api/kb-media/DjMfbp3Izo7RytxrSuHcWleonje)

### **Port Mapping**

Here, change the Flask port to 5002. Please ensure the corresponding port is allowed in the server firewall.

```
sudo ufw allow 5002
sudo ufw status
```

![](https://www.waytoagi.com/api/kb-media/LFkZbaVYSoVrLUxORRSciQcVnSh)

If you need to provide external network access, be sure to apply for a public IP from your ISP and set up port forwarding on your router to expose the internal Flask server address.

![](https://www.waytoagi.com/api/kb-media/SnYAbRBcgorDiuxBd5FcZ4oVnvh)
![](https://www.waytoagi.com/api/kb-media/CqefblKSLoWckoxSufJcx8Mgnia)

### **Inference Time**

Under 5G and WiFi networks, the majority of time is spent on large model inference. The inference time for LLaVA 1.5 13B 4-bit is approximately 9 seconds.

![](https://www.waytoagi.com/api/kb-media/VTIMbKPNsoxYsHx8VyWcUU2Bnhc)

In contrast, BakLLaVA 7B 4-bit can be accelerated to around 800 milliseconds. This speed is comparable to on-device direct inference.

![](https://www.waytoagi.com/api/kb-media/Io0qbsDQwofzPAx5F0Pc1X13nhf)

## **Mobile Access**

You can access the service on your phone by visiting `https://your-machine-ip:5002`. It has been tested on Huawei phones using Firefox and on OnePlus phones using Chrome (for external network access to the camera, you need to set “Safe Browsing” to “Standard Protection” mode). These two browsers offer better support for HTML5 APIs. **Feedback on the performance of other mobile browsers is welcome in the comments section.**

Main features include:

- **Switch Camera**: Toggle between front and rear cameras
- **Describe**: Trigger a single LLaVA inference
- **Narrate**: Read the result text aloud using speech synthesis
- **Prompt**: Customize the system prompt

**「Preparation is complete — in theory, you only need to bring your phone and you’re ready to head out.」** It feels like having a low-spec AR device in your pocket. Isn’t this quite similar to the AI Pin?

![](https://www.waytoagi.com/api/kb-media/ZiyRbRMiionHAfxWmkscob0Qnkf)

**「It’s not that the AI Pin isn’t good — it’s just that using an idle phone is far more cost-effective.」** With a home computer and a spare phone, you get inference in just a few seconds, infinitely expandable AI models, and a freely customizable architecture. At that point, what more could you ask for?

### **Custom Prompt**

**「Custom prompts instantly unlock tremendous extensibility.」** It makes one reflect on how traditional computer vision models (like mask detection) required massive amounts of training data and countless hours of model training. What if the requirement changes to hard hat detection instead…?

![](https://www.waytoagi.com/api/kb-media/NS1Jb1FYdoJqZqxpIRkcewVinIc)

This approach is **ideal for demos and represents the best low-cost method for commercial validation**. There is no cheaper or more complete way to test an entire end-to-end engineering pipeline than through custom prompts.

**With powerful prompts, most problems can be solved.** As more projects are deployed, it becomes increasingly clear that 90% of issues can be addressed using a strong foundational model (such as GPT-4) combined with well-crafted prompts. Of the remaining 10%, 90% can be solved by connecting a custom knowledge base via RAG. Only **「about 1% of problems」** truly require algorithm engineers to perform fine-tuning. Let’s keep pushing toward AGI.

### **Description Mode**

This mode can recognize objects in view and supports both Chinese and English. It generally understands the content of a scene and can be used for basic intent recognition or scene content analysis.

![](https://www.waytoagi.com/api/kb-media/WO5GboZpoolt93xxF4IczymsnWb)

### **Conditional Trigger Mode**

By crafting specific prompts, the system matches results as “yes” or “no” and responds accordingly on the frontend. In the current demo, when “yes” is matched, a thumbnail of the qualifying image is displayed in the top-left corner.

![](https://www.waytoagi.com/api/kb-media/Yq1cbhCzJosC4QxEzRAcE790nlb)

![](https://www.waytoagi.com/api/kb-media/J6ykbnagZo2QWjxNYUZca7kxnYc)

This can be further extended in many ways — for example, integrating AIGC for secondary creation, drowning detection reporting, fire detection, mask detection, and more. The possibilities are vast.

### **Automatic Mode**

The frontend periodically calls the inference service, enabling fully unattended automation. The backend can perform real-time inference based on detected scenarios. This raises the question: **「What scenarios actually require real-time inference?」** Wouldn’t **asynchronous analysis** be more economical for dashcam footage?

Some practical use cases that come to mind:

- **Road Conditions**: If you encounter traffic incidents, congestion, or other road situations, sharing a photo from the front of your car can help others understand the real situation.
- **Scenic Views**: When you drive past a beautiful landscape, sharing the view captured in front of your car lets others enjoy the beauty of your journey.
- **Gaming Interaction**: With the current popularity of monster-collecting games and the resurgence of Pokémon, using LBS to go outside and catch virtual creatures doesn’t seem excessive at all.

## **Pros and Cons of LLM Applications**

**Advantages:**

- Extremely high adaptability. Prompt engineering makes it easy to **adapt to all kinds of quirky requirements**.
- Significantly lowers the bar for traditional algorithms. Most functionality is provided by the large model, especially in handling unstructured information.
- The API-based access pattern of large models greatly simplifies requirements for edge devices. It can be easily adapted to Android, iOS, HarmonyOS, or various embedded platforms.
- **「AGI is inevitable. Embracing the future is the right direction, even if the road ahead is difficult.」**

**Disadvantages:**

- Inference latency remains the biggest bottleneck. Traditional object detection or face recognition can be optimized to 100–300 ms, whereas large models often take around 10 seconds. This limits applicability in many real-world scenarios.
- Hallucinations and error rates are still relatively high. Combined with the latency issue, this makes multi-stage, complex applications quickly impractical.
- In most production deployments, cloud data centers are still required. Submitting images inevitably raises privacy concerns.
- Commercial private deployment is a must-have. Current open-source models lag behind GPT-4 by more than half a year. There is still a long way to go for technical teams.

## **Future Outlook**

You can't make a meal without ingredients. The car mount is already in place—now I just need to take a drive, load the prompts and source images collected by the backend into the dataset, and then take the work further.

![](https://www.waytoagi.com/api/kb-media/Iqk8bbyqyo7zLwxObwHcTm1QnFd)

Life is a one-way journey; all you can do is **"try not to miss the scenery along the way."**

It's 2024 now, so let me wish everyone an early Happy New Year. With large language models, technology has been democratized—the only things left to compete over are **"creativity and the ability to bring ideas to engineering reality."**


## **Source Code Download**

![](https://www.waytoagi.com/api/kb-media/Z389bey5ZoDb4Lx2WqSc69L3nQf)

For the files related to this installment, go to the WeChat public account "Deep Awakening" and reply "llava01" in the backend to get the download link.

Future versions will continue to be updated as open source—if you're interested, you can also star it on GitHub.

```
https://github.com/bluishfish/llavaprompt
```

> 🎬 This is the Feishu attachment "llavaprompt.zip", [view it in the Feishu knowledge base](https://waytoagi.feishu.cn/wiki/XOucwqHrmiNlf5kK01xc61Vsnef)

![](https://www.waytoagi.com/api/kb-media/RZFtbms5nobnI8x2H3NcM9KTnyb)
