Thursday, June 19, 2025

Run Ai locally, LLMs in Your android device

Important Download links for Termux, Simple HTTP Server, OSB.html, Ollama

OSB.html 

https://play.google.com/store/apps/details?id=com.phlox.simpleserver&hl=en

https://termux.dev/en/

https://play.google.com/store/apps/details?id=com.termux&hl=en

https://ollama.com/search

Important Termux commands (pkg install ollama , ollama serve, ctrl c , exit)

 Use this HTML method provided below, it works perfectly and The Osb android apk will launch soon. 

This kilab-ai application lets you run large language models in your mobile android devices or notebooks.





You get to choose which ever model you want to run. Your personal data stays with you and no subscription required. You can run this even when you are offline.

Here follow these steps to have your personal chat bot.

Step 0:
Install Termux in your android device. get the app from Fdroid as Termux is officially maintained there. Also try the termux available in playstore



Termux from playstore is old, not updated so, that may or may not work. 



Step 1:
Give Termux storage and send notification permission from device settings  if needed

Open Ternux and type

pkg install ollama




It will take some time to download that. when download is done type


ollama serve

this will start the ollama server on its own localhost port.




Step 2:
Download this html file, OSB.html

If you are new to git then press the download raw file button on the right corner or copu the entire code, paste it in .txt file, then rename it to osb.html
 
 
It is the web UI created to connect with the ollama server and send prompts

place it in internal storage download directory . the directory you put it in is really important. You can choose any directory but you have to remember it.

Step 3:
Go to play store and install Simple HTTP Server app


open simple HTTP server. Press the folder icon and select the download folder or exact directory where you have put the OSB.html
When you are done press start and it will host your file as a server so that ollama can connect with the web UI app.


I placed my file on appdev that's why I chose it


Step 4 :
Go to the google chrome browser and exactly type,

http://localhost:8080/osb.html



now the web UI will open. press the O button in the web UI.
In the Pull new model box type. It is for testing as it will work on 4gb ram and quiet fast.
 
smollm:135m 
 
then press the pull model button. this will pull any model you can find on ollama's official site but you have to type the exact model name
now on set default model also type this name smollm:135m
and set it as default model.





You can remove any model if you like


Step 5:

Press the O button again and type hi , press send. If every thing is ok then you will get a reply.



If this model works then pull

gemma3:1b

gemma3:4b 

only gemma3:4b is capable of describing images. there are lots of models in ollamas site you can test any of them. 

also pull 

gemma3:4b 

send an image and wait for the response.  Test with different models for your device which ever feels suitable, daily driver it.



Rather searching online ask the model if you have any question. More features will be updated in future.
Coolest feature is that you can chat with multiple models. select from the drop down list


Step 6:
Go to the chrome menu and press add to home screen  
Then press install
Then press install again on the pop up window
then press add 

this will install it to your device as an application so that when ever you want you can open it.

Step 7:
To close termux , open termux.

Press ctrl 
then press c

then type exit
 it will exit termux.
Stop the HTTP server as well.


If you want to use the app again, you just have 3 steps. 

1. open termux type ollama serve
2. go to HTTP server press start  and
3. open the OSB app from your home screen as you have already installed it

After pulling any new model
if your query runs slow then exit termux and ollama serve again
this typically happens when any new model is pulled 

I have tested on Motorola edge 50 fusion 12gb ram and Nokia 6gb ram , models up to 4 billion parameters run fine, models up to 2 billion parameters are really fast.

You can also use OSB in your computer then you need to run your own server from the file directory.


For Laptops :

Install ollama 
open ollama

Install python

search in your device and open cmd
start a python server,  type or paste this python -m http.server 8080

Place the OSB.html file in C:\Users\wasif> this is my directory your might be different, will be visible in your terminal when you open it.

go to your browser type http://localhost:8080/osb.html

And use it as before. If you further want to change any thing then modify the osb.html code.



No comments:

Post a Comment

Run Ai locally, LLMs in Your android device

Important Download links for Termux, Simple HTTP Server, OSB.html, Ollama OSB.html   https://play.google.com/store/apps/details?id=com.phlox...