Some Bits: Nelson's log

12 posts in August 2023

Eufy RTSP stream

I have a Eufy IP camera, a cheap $35 Security Solo IndoorCam C24. It does support RTSP but it’s not easy.

To get it working, I had to use the mobile app and get to the settings for the camera. Then open General / Storage / NAS (RTSP). The setup flow talks all about a Synology NAS which is confusing, the docs say that’s all that’s supported. But really what they mean is the Synology RTSP client is the only one they want to answer questions about; it seems to work with any RTSP client, including VLC.

Anyway, you go through the flow and the end result is you are given a stream link. It’s of the form rtsp://username:password@192.168.###.###/live0. It generates a random username and password and claims it’s doing digest security.

RTSP support seems hit or miss with Eufy. Not clear which all devices have. Also they’ve disabled or broken it in the recent past, judging by Reddit discussions. Maybe in response to one of their many security disasters. Anywat this particular “Indoor Cam 2K” works, with firmware version 2.1.8.7.

Eufy apparently does not support Onvif.

Also Eufy is a bad product and should probably be avoided. They were recently caught sending images to the cloud even when the camera was explicitly configured not to do that. That’s not just an honest security mistake, that’s some product manager making a decision to harm their users. It speaks badly of the company. Too bad, it’s an Anker product and works pretty well. I generally like Anker!

YouTube TV vs geolocation

YouTube TV needs to know your home location to decide whether you have the right to watch local TV channels, also sports broadcasts. It’s an awkward impedance mismatch between the global Internet and 1920s business models born from the radio era. Anyway, the tech is a PITA for me.

Summary: sometimes you might have to log in and manually press an “update my home area” button. I do this from my phone when I’m really physically in that area, because the phone geolocation works.

Update (July 2024): just had to do this again and it was more complicated than I remember.

  • Try to watch YT TV in my desktop browser, get the error about location
  • Open YT TV app on phone
  • Tap little portrait of me in upper right
  • Click “Location” in my Account
  • Click “Update” for “Current playback area”, even though it shows the right area already
  • It says “updating...” and then “you have successfully updated...”
  • Desktop browser can watch the show again

In detail.. My home metro is the Sacramento area, where Grass Valley is. That is the main place I watch TV, where I live. But I do travel and also spend a fair amount of time in San Francisco. I always want YouTube TV to treat me as a Sacramento metro resident. This all should be in line with YouTube TV’s policies, in particular you are allowed to travel and watch shows from home as long as you log in from home every 3 months.

The problem is the main device I watch YouTube TV on in Grass Valley (a Roku TCL TV) is using Starlink. And Starlink’s IP addresses make me look like I’m in Los Angeles. So YouTube TV never sees me logging in from what it thinks is Sacramento. It’s really stupid and a great example of why IP based geolocation is a bad idea.

The easy work around has been to watch YouTube TV from my cell phone from time to time. The phone app seems to use the phone’s actual location, not the IP address, and all is well.

Apparently I forgot to do that and the app on a Roku in San Francisco refused to show anything until I logged in again from my home area. Same thing happening here in my web browser. Everything locked.

Finally on the phone I found a way to set my home area. It was almost like I had to set it up again, manually pressing a button saying “yes I really am home now” (in Grass Valley). Once I did that my account was unlocked and all the other devices worked again with Sacramento as my home area.

What a stupid farce.

(Coincidentally, just yesterday I set up my desktop computer to spoof my location so I look like I am where I really am in Grass Valley, despite the Starlink IP being in LA. Somehow that didn’t seem to work with Youtube TV. Maybe just a cache problem, or maybe they get upset if the IP location doesn’t match the browser geolocation? My impression is YouTube TV is doing the minimum to comply with licensing requirements and is not too worried about catching dastardly people who spoof their locations, but who knows.)

You know what videos I have that don’t have georestrictions? The pirated ones. Once again the illegal option is a better user experience.

What my phone was talking to

After setting up some monitoring I’ve got some data on a little over 2 days of Android phone activity. But I don’t really know what’s going on with my phone other than it’s a lot.

The phone is a Pixel Phone, nothing extraordinary, not used often. I do have a couple of background things running (Syncthing and GPSLogger). Mostly I’m curious why so many apps are sending network traffic every few hours. So I set up NextDNS and Netguard to learn more. Honestly, I didn’t learn much from this exercise. But here’s what I got.

NextDNS Analytics shows 18,000 queries, 35% of which were blocked for being trackers / ad related.

Top domains blocked were for Braze, Urban Airship, Optimizely, Crashlytics, Twilio Segment, and Google Analytics. Ie: all basic user surveillance, ordinary marketing bullshit.

Top unexplained domains allowed were Google SUPL (a location thing), federatedml-pa.googleapis.com, youtubei.googleapis.com, play.googleapis.com, and firebaseremoteconfig.googleapis.com. Guessing these are all related to Google services that are part of Android OS. (A whole lot of network connections go to 1e100.net addresses but all that tells me is they’re hosted by Google.)

Netguard is showing me a lot of my apps wake up and do a little network stuff every few hours, despite me not actively using them. For instance Amazon Music (which I haven’t used in weeks) wakes up once an hour and makes several network connections totalling 1-2MB. Once an hour! What the hell? I deleted that app.

Other apps seem to connect only once a day and some (like HSBC’s banking apps) don’t connect at all. Despite being apps I do use regularly. Presumably some are suppressed because Android identified them as unused and deprioritized them. I’ll note that many open source apps seem better behaved. And shout out to the apps that have “no Internet permission”, typically apps that don’t need them.

I have a theory that a lot of this sparse traffic is basic app telemetry. For instance it looks like Grindr is firing off requests to Crashlytics, Google Analytics, and Scorecard Research. (And also its own DNS-over-TLS queries once it figures out I’ve blocked those on the system level.) Remarkably the other gay dating app I have installed, Growlr, seems to make no queries at all when not used.

There’s an interesting splodge of queries at 2023-08-29T20:45. It’s plausible that’s when I unlocked my phone, I could imagine a bunch of apps taking advantage of the device waking up to phone home.

One last tool I tried is Google’s “Non-carrier data usage” report; that shows you app data usage for a month. But most of that is stuff I did on purpose, like reading a newspaper. Just about 20GB for a month. The first surprise on the list is Tapet, an app that makes random background images; that comes in at 172MB. I do use that app (and love it!) but none of its features are networked, so where’s the data going? I couldn’t figure it out, although their privacy policy suggests usage surveillance. Amazon Music is up there at 42MB. A blood pressure monitor app I barely use is at 39MB. Etc.

Bottom line, I didn’t learn much. Honestly trying to figure out what’s going on with these limited tools is difficult. Netguard has the ability to capture full traffic in PCAP files but trying to comb through those sounds like a nightmare, especially since it’s almost all SSL.

There’s definitely a cost to keeping old apps installed on your phone. Even if you never use them they still wake up and do stuff on the network.

Update: Android has some guidance on excessive mobile network usage in background. “Android vitals considers background network usage excessive when an app is sending and receiving a combined total of 50 MB per day while running in the background.” This page seems mostly concerned about battery consumption, not bandwidth.

Google APIs

One interesting bit of data from the DNS logs are various Google API queries. It’d be interesting to know what all of these services are; like what’s geller-pa?

228 crashlyticsreports-pa.googleapis.com
218 youtubei.googleapis.com
218 federatedml-pa.googleapis.com
180 play.googleapis.com
157 firebaseremoteconfig.googleapis.com
141 android.googleapis.com
130 firebaseinstallations.googleapis.com
114 play-fe.googleapis.com
107 androidattestationvalidation-pa.googleapis.com
100 googlehomefoyer-pa.googleapis.com
90 http://www.googleapis.com
79 notifications-pa.googleapis.com
76 android-context-data.googleapis.com
70 userlocation.googleapis.com
60 geller-pa.googleapis.com
39 telephonyspamprotect-pa.googleapis.com
37 translate-pa.googleapis.com
36 update.googleapis.com
36 paperwork-pa.googleapis.com
36 firestore.googleapis.com

Top Domains

And here’s the top domains overall by DNS queries (count is number of queries, not overall traffic).

588 sdk.iad-06.braze.com
548 device-api.urbanairship.com
400 logx.optimizely.com
386 firebase-settings.crashlytics.com
384 api.segment.io
377 ssl.google-analytics.com
265 supl.google.com
228 crashlyticsreports-pa.googleapis.com
218 youtubei.googleapis.com
218 federatedml-pa.googleapis.com
188 discovery-v6.syncthing.net
180 play.googleapis.com
172 googleads.g.doubleclick.net
157 firebaseremoteconfig.googleapis.com
154 app.rain-alarm.com
151 device-metrics-us.amazon.com
143 static.withings.com
141 discovery.syncthing.net
141 android.googleapis.com
140 g.whatsapp.net
136 meta.wikimedia.org
132 rest.locuslabs.com
131 prod.rudderstack.withings.net
130 firebaseinstallations.googleapis.com
129 clients4.google.com
128 remote-data.urbanairship.com
126 graph.facebook.com
122 slack.com
120 http://www.googletagmanager.com
120 api.pocketcasts.com
119 clients3.google.com
118 http://www.googleadservices.com
118 ad.doubleclick.net
117 msh.amazon.com
114 sb.scorecardresearch.com
114 play-fe.googleapis.com
114 discovery-v4.syncthing.net
111 i.ytimg.com
111 assets.adobedtm.com
111 api.amazon.com

Faking geolocation in Chrome

I finally found a good extension for controlling browser geolocation: location-guard. It’s open source, works in multiple browsers, and has some smart features. This replaces my old config hack for Firefox on my desktop computer and I’m mostly using it to work around Starlink’s geolocation limitations.

Update July 2025: no one ported Location Guard to MV3 so Google has now broken it. I’m using Cloaq instead. It’s not quite as fancy but seems to do the job. However read the notes about their use of the debugger API and having to launch Chrome with a shortcut. Nuisance!

Update April 2026: I’m using this Location Guard (V3) now. It’s on GitHub here but I didn’t verify that the version from the Chrome web store matches that code.

I used this site to test it (although it bugged out on me once...) Probably this test site is better, it has more diagnostic detail. The Chrome permissions at chrome://settings/content/location are also worth examining.

It’s important to me this type of extension be open source. The extension has to have permission to access all websites and all data, so it takes a lot of trust to run it. And this kind of extension has a bad history of being bought and subverted (see also: the sad Hover Zoom story.)

Location Guard works by overriding the geolocation API in the browser Javascript. It’s pretty clever about it. By default Location Guard adds 500 meters of random noise to your current location. It keeps a cache of the location it gives to the site for 30 minutes so you don’t appear to be jumping around randomly. It also updates the accuracy data on the reply to indicate the location is not precise.

I worry that this kind of randomization is not really great, that if a site collects enough samples they can average away the noise. I’ve always thought it was better to just truncate coordinates. But in practice it’s probably good enough for most sites. Also I could be entirely wrong about this, the FAQ references some academic research about why this particular kind of Laplacian noise works.

But I won’t want to fuzz my location, I want to appear 400 miles away. For that I use Fixed Location. There’s a confusing option to that: “Fixed location disables geolocation. warning: this also disables the permission dialog”. I’m running with that turned off, because I definitely want to get a notification if a site is trying to geolocate me. The relevant code is here. It seems to work to let you still deny location permission if you want.

Note if you’re testing this be sure to use the extension option to delete local cache as needed.

What is my phone talking to?

Trying to figure out what all on the network my Android phone is doing. Two avenues.

One is using NextDNS as a private DNS server. I’ve been doing this for a year+ as an ad blocking measure. It provides logs and some high level analytics for DNS traffic. I don’t love messing with DNS but they did a great job on this service. NextDNS shows me info about where my phone is connecting to, but not specifically which app. Also it’s skewed a bit by caching since it’s only DNS queries, not network connections. Anyway it already got me to remove TikTok (I hadn’t used it in a month and it was making 3 queries a minute). I’ve also learned about braze.com, some surveillance system that is happily being blocked.

NextDNS analytics

The other is using NetGuard, an open source app firewall. It works by being a locally hosted VPN. It’s main use is to block network to individual apps (like, say, TikTok). But it has some auditing capabilities, albeit with awkward UI. I currently have it allowing all connections but displaying notifications for new ones. Which is pretty noisy but is giving me a view of what’s happening on my phone. Syncthing is sure chatty! And I’m wondering WTF Uber and WhatsApp are doing consuming data when I’m not using them (it should not be polling for notifications.) There’s also a detailed log view and it will even export PCAP if you really want to get into the data.

Product desire

What I really want is a per-app audit of network activity with drill-down to see details. But the main view is just a scoreboard. One row per app, sortable by bandwidth and # of connections and the like. Just a passive monitor, no filtering needed. I’ve wanted something like this for 20+ years on every computer and router I’ve owned and am always disappointed.

Starlink publishes performance maps

This is really great; Starlink is publishing performance metrics on a map. Download, upload, and latency. Per-state in the US, per-country in smaller places. “Metrics range from 20th to 80th percentile for the “Standard” service plan only, during local peak hours, and are refreshed monthly. Map coloring is based on the median for each metric”. That’s pretty useful and way better than I’ve seen any other ISP do.

Download speeds, darker is slower

In California they report 44–139 Mbps down, 8–17 up, and 39–52ms latency. That’s pretty well in line with what I measure (over the whole day, not just peak hours). My latency at 51ms is on the worse edge of that.

Not sure I can draw many conclusions from the map coloring. Some broad regional patterns, but nothing specific. The per-state binning is pretty coarse.

Some random home-scale LLM facts

I’ve been learning a lot about small-scale LLM models running on your desktop by reading /r/localllama. None of this is novel, just absorbing common wisdom. I’m linking to some sources but these are by no means authoritative, just useful for feels.

  • They tend to talk about models in terms of number of parameters.
  • LLaMa 2, which many models are derived from, comes in 7B, 13B, and 70B sizes. 70B means 70 billion 16 bit weights. They were trained on 2 trillion tokens as input.
  • Number of parameters dictates memory needed. LLaMa 2’s 70B is 140GB. But folks often downsample to 4 bits when running them so it’s just 35GB. (Or less?)
  • Desktop CPU RAM is fairly cheap (up to 128GB), but VRAM is expensive if you’re running on a GPU. The most expensive gamer GPU (an NVidia 4090 at ~$2000) has 24GB of VRAM.
  • You can also chain multiple cheaper GPUs to get more total VRAM. Beware a single 3090 takes three motherboard slots, so you need a special motherboard and case to have room for two.
  • Specialty AI chips like the A100 or H100 support 40-100ish GB per GPU.
  • 70B is said to be enough to approach ChatGPT 4.0 levels of quality but I have my doubts.
  • The GPT4All models I’m running just on my CPU with GPT4All are 6-13B.
  • GPT4All uses GGML / llama.cpp to run things. it has various quantizing algorithms, it’s not just “truncate the lower bits”. That driver targets 4, 5, and 8 bit integer quantization.
  • GGML can offload part of the model to run on the GPU and use CPU for the rest. This lets you run bigger models than can fit just on the GPU.
  • This discussion about folks running LLMs on an NVidia 4090 with an Intel i9 is interesting. That’s the highest end reasonable home hardware, maybe $4000ish for a full system? They talk about running 70B models at speeds of 1-2 tokens / second. Which is not fast but maybe acceptable for an interactive session.

Update

Some new facts:

  • Running a 70B model (at 4 bit quant?) at home takes 48GB of VRAM. Folks are using two high end GPUs like 3090s or 4090s. Talk of generating ~15 tokens / second. At the low end, two Tesla P40s will work and are cheap.
  • Running on your own leased cloud computer is totally reasonable. See this discussion and this one. It may cost about $1500 a year to lease, compared to $4000+ to buy hardware.
  • Inference can use up to 700W of GPU, Call it 100W for the computer and you get to about 35¢ an hour just for PG&E electricity. OTOH in casual use you’re not running inference full-out, so actual power will be much less.
  • RunPod keeps coming up in discussions about cloud providers.
  • Folks say it costs about 60¢ an hour to run a 70B model on a cloud server. Apparently this can be done for a single user without too much drama. Scaling that up to 100+ is going to run into availability problems.

task-spooler

This Hacker News discussion taught me about a great new-to-me tool: Duc Nguyen’s task-spooler. It lets you queue up a set of jobs on a Linux box and have them run in parallel in the background. It’s available in Ubuntu and has the shell command tsp.

I’ve used GNU Parallel before for this and it’s great but the model there is you run one big command and the jobs run in parallel all together. The queueing interface in task-spooler means you can keep throwing work at the system and it gets done eventually. Task queues are one of the great computing paradigms IMHO, along with event publish/subscribe.

The interface is very easy. You run tsp command to enqueue a new command, it returns immediately. It sets up a background process to run the command if there isn’t already one and puts the job on the queue. The default parallelism is only 1; you can run tsp -S 4 if you want to run 4 jobs in parallel. Output is written to files in /tmp by default.

There’s more complex commands for querying job status, etc. There’s minimal support for more complex queue management. including options for “wait for a job” and “the job will be run only if the job of given id ends well”. I wouldn’t use this to replace a complex task queue system but it’s nice to have those basics available.

$ tsp -K
$ ps xu | grep tsp
nelson    3983  0.0  0.0   6304   652 pts/0    S+   11:45   0:00 grep tsp

$ tsp sh -c "sleep 1; date"
0
$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=0/1]
0    finished   /tmp/ts-out.H7AJLG   0        1.00/0.00/0.00 sh -c sleep 1; date
$ cat /tmp/ts-out.H7AJLG
Mon 21 Aug 2023 11:45:47 AM PDT

$ !ps
ps xu | grep tsp
nelson    3985  0.0  0.0   2548    84 ?        Ss   11:45   0:00 tsp sh -c sleep 1; date
nelson    3999  0.0  0.0   6304   648 pts/0    S+   11:46   0:00 grep tsp

$ tsp -K
$ tsp -S 3
$ date; for i in {1..6}; do tsp sh -c "sleep 5; date"; done
Mon 21 Aug 2023 11:54:10 AM PDT
0
1
2
3
4
5

$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=3/3]
0    running    /tmp/ts-out.Ifxnc9                           sh -c sleep 5; date
1    running    /tmp/ts-out.estpmo                           sh -c sleep 5; date
2    running    /tmp/ts-out.vDtaPG                           sh -c sleep 5; date
3    queued     (file)                                       sh -c sleep 5; date
4    queued     (file)                                       sh -c sleep 5; date
5    queued     (file)                                       sh -c sleep 5; date

$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=3/3]
3    running    /tmp/ts-out.IgWMfx                           sh -c sleep 5; date
4    running    /tmp/ts-out.tSSCYL                           sh -c sleep 5; date
5    running    /tmp/ts-out.j003cY                           sh -c sleep 5; date
0    finished   /tmp/ts-out.Ifxnc9   0        5.00/0.00/0.00 sh -c sleep 5; date
1    finished   /tmp/ts-out.estpmo   0        5.00/0.00/0.00 sh -c sleep 5; date
2    finished   /tmp/ts-out.vDtaPG   0        5.00/0.00/0.00 sh -c sleep 5; date
$ tsp -t

Mon 21 Aug 2023 11:54:20 AM PDT

Starlink vs Hurricane Hilary

I’m wondering if Starlink service was affected by the hurricane? I’m in Grass Valley where we got some clouds but no significant rain. But my packets are routed through Los Angeles. I don’t know if that’s entirely in space or if they go to earth in some invisible relay closer to me, but LA is definitely where the packets first appear in traceroutes.

Anyway, coincidentally I noticed an unusual service degradation yesterday around 9am to 6pm, about when the storm was passing through. Sort of? It’s not exactly time-correlated but The effect was worst around 4pm. Hurricane Hilary passed closest to Los Angeles at just about that same time.

Honestly I thought it was congestion-related but the effect is much larger than usual. Packet loss went up to 4% (typically 1%), round trip time up to 100ms (typically 50ms). Speed tests don’t show anything obvious, maybe throughput is a little worse.

It’s plausible there’d be an effect. The satellites are well above any weather but I’ve seen rain fade impact signal quality in the past when I’ve had strong local storms. (By far the biggest risk of hurricanes is the wind and your local antenna mount.)

There’s a discussion of a related observation on Reddit.

Here’s a graph of the last two days.

Starlink detailed timings

Over on Reddit user panuvic is posting a series of interesting timing graphs from Starlink packets. Most recent post here. I have no idea who this is or what they’re doing but it’s very interesting. Some of their posts make it sound like they’re measuring with independent radio gear listening in on the transmissions.

Some things I noticed, using his graphs.

Above is a graph of round trip times over a few minutes. Handoffs to a new satellite are typically multiples of 15 seconds. What’s interesting is the highly variable latency between satellites, like 20-70ms. That’s way more time than can be accounted for by radio propagation delay and physical distance. Maybe it’s queueing, some satellites are busier than others?

This is handoffs for two different locations. The two graphs are synced in time. If you look closely, so are the handoffs. They both occur at the same second, despite being two completely different installs at different locations 2400 miles apart. Isn’t that strange? I’ve heard other people speculate that every Starlink dish in the world schedules handoffs at 12, 27, 42, and 57 seconds after the minute. That seems wild to me!

Graphs of latency measured asymmetrically; bottom graph is one way delay from the Internet to the customer, middle is one way from the customer to the Internet, and top is two way. What’s interesting here is the banding in the receive timings, it looks like 4 or 5ms jumps in latency. I’m wondering if that’s some sort of time division multiplexing in action. Miss your transmit window on the satellite and have to wait for the next one?

Game streaming with GeForce Now

A couple of weeks ago I tried streaming a game to my Chromebook via GeForce Now. It worked surprisingly well in some ways but the video quality was bad enough it wasn’t much fun.

The main goal was playing Satisfactory (a first person game but slow, not twitchy) on my Chromebook. I paid for the Priority service, which gives you 1080p @60fps and a powerful enough server. It all worked OK and the experience was nearly seamless. But the video quality was awful. It’d constantly drop down to really blurry graphics. If I sat still and didn’t move the camera it’d look OK but the moment I moved it was awful.

I think it may have been the WiFi I was using. It was good WiFi and speed tests showed 50Mbps or more with low latency. But even good WiFi has some packet loss and that’s the enemy of quality. FWIW performance was better on my Windows machine wired to a fast gigabit fiber. Also pretty good for ethernet + Starlink. But good heavens if a streaming game service can’t work on good WiFi what’s the point?

I was able to improve things on the WiFi a bit by disabling “adjust for poor network conditions”. Before I did that the stream would regularly drop from 1080p as far down as 480p for a couple of seconds. It seemed to run much better locked to 1080p.

I don’t think it was the Chromebook; it looks bad on my gaming PC too. It’s possible paying $20 for the Ultimate service would help things. I’m fine with just 1080p@60 but maybe paying for a better server results in a better quality video stream?

Even on the fast ethernet networks the video compression quality is really weird. Here’s some screenshots comparing the same scene in three scenarios. (Click to enlarge, they are all lossless PNGs). 1080p on the native game (ie, perfect). Then the best picture I could get out of GeForce Now streaming. And finally the worst picture from GeForce Now. Captured by spinning the camera and snapping a photo. The game is not doing motion blurring, it should look sharp. These were all generated on my Windows gaming PC, GeForce Now running in Chrome.

That right image from GeForce Now is just unacceptable to me. And that’s what you see most of the time, when the camera is in motion. The middle one where GeForce Now is doing its best is also not great. I can only think that compressing a video stream at 60 fps with very low latency is hard and their streaming platform isn’t up to it.

FWIW the streaming client seems to use up to 30Mbps for the 1080p stream which suggests it’s very fast compression. There’s options for limiting the bitrate and I tinkered with those but mostly have left them unlimited.

Good things.. The latency is great, even with a 50ms+ lag from Starlink it feels very responsive. I didn’t try a twitchy shooter or anything but it felt like I was playing locally. The user experience is also very simple. It all runs in a browser and you can easily use your existing Steam library (including Steam Sync for save games). The free level is good enough you can see how it works but you definitely want to pay for the $10/mo premium for higher quality. (Not sure the $20/mo is worth the improvement, I didn’t try it.)

BTW there’s precious few docs. Press Ctrl-N for streaming performance stats and Ctrl-G for the GeForce Now settings.

I dunno, it’s remarkable this technology works at all. Game streaming has worked for over 12 years now! But somehow it’s never quite caught on. GeForce Now solves a lot of problems: easy to use, simple business model without some weird game subscription required. But the video quality was just not good enough, particularly on WiFi.

Running my own LLM

No original work here, just summarizing how astonishingly easy it is to install and run an LLM on your own computer using Simon Willison’s fantastic llm tool. Simon has been on an absolute tear with tooling for LLMs lately, amazing work. A bit hard to keep up but between his Mastodon feed and his blog I can sort of follow along. See his list of plugins for a sense of how broad the tool is.

I think this current moment in AI development is amazing and fascinating. And it’s great so many models can be downloaded for free experimentation. Simon’s tool makes this easily accessible.

Getting started

Here’s what I did to host my own LLM in just a few minutes:

  1. pip install llm
  2. llm install llm-gpt4all
  3. time llm -m orca-mini-3b ‘what is the capital of france’
    The capital city of France is Paris.
    real 0m2.337s user 0m7.701s sys 0m0.168s

That’s it, literally three commands. All automagic. The slowest part is downloading the 4GB of weights for Orca. Simon did a fantastic job with this tool. See the detailed docs or read on for my usage notes.

Technical details

llm was originally designed as a front-end for the OpenAI API but has a plugin architecture with lots of plugins. There are some other plugins for hosted models like Google Palm, Replicate, Claude. But I’m more interested in running the model locally. My example above uses llm-gpt4all, which downloads and runs GPT models downloadable in some standard format. (There’s some 13 models there, most are about 7GB big.) There’s also hosted plugins for Llama, MLC, and Mosaic.

I installed this on my year-old Linux server. It’s middle-of-the-road home system hardware, notably with no external GPU. So not a great match for AI but then I don’t have to sweat the details of making GPU access work on Linux. When running the GPT models they seem to be using 6 or 8 threads, which suggests they want real cores and not hyperthreads. Not sure how much RAM it uses; the docs say 4GB for the 1.8GB Orca model but I’m observing more like 1GB.

Performance of the smallest Orca model is fast enough on my CPU to be interactively usable; 2-3 seconds for short queries. Some others are significantly slower; I have to think a lot of these are designed to run on a GPU.

The main command is llm prompt for querying the LLM. It has a -c flag for an interactive session, similar to ChatGPT’s web interface. Otherwise each question starts from a blank slate.

Each model comes with a system prompt baked in that primes the LLM for your query. Ie “You are an AI assistant that follows instruction extremely well. Help as much as you can.” You can customize this; for instance Simon advises telling Llama “you are funny” if you want jokes.

Not sure where all LLM is storing its model files, they aren’t in the Python venv. Some of mine are in ~/.config/io.datasette.llm. Another place is ~/.cache/gpt4all. These model files are huge, often over 10GB each, so if your home directory is backed up over a network or something beware.

In summary, Simon’s LLM tool is a great frontend driver for various LLMs. It handles installing plugins to drive the models, downloading models themselves (for local hosting) and key management (for remotely hosted AIs). It also has some nice features for tracking your usage like llm logs for access to a database of your chat history.

Some model outputs

Some quick notes from me trying all the self-hosted models with the test query “what is the capital of france”. Note I tried several versions of LLaMA 2 using different llm plugins. All timings are based on using a simple Intel CPU; results should be much faster with a working GPU.

gpt4all results

These are all using the gpt4all plugin, which seems to run best on my system. All of these give a short output of “The capital city of France is Paris.” or something very similar.

  • orca-mini-3b. 2.4 seconds.
  • orca-mini-7b. 4.2s.
  • orca-mini-13b. 7.6s.
  • ggml-model-gpt4all-falcon-q4_0. 3.9 seconds.
  • wizardlm-13b-v1. 5s. (also uncensored).
  • nous-hermes-13b 5s.
  • GPT4All-13B-snoozy 5s.
  • llama-2-7b-chat. 10s

One reason these are so fast is the output is so short, presumably an artifact of how the LLM was set up by the plugin. (The prompt is “Human: {{{user input here}}}. Assistant:” If I ask orca-mini-3b “what is the capital of france and tell me a bit about it” it generates a full paragraph and takes 9 seconds instead of 2.6.

The capital city of France is Paris, also known as “The City of Lights”. It is located in the northern central part of France and is the country’s largest city with over 2.1 million people living there. Paris is famous for its iconic landmarks such as the Eiffel Tower, Notre-Dame Cathedral, the Louvre Museum, and the Arc de Triomphe. The city is also known for its fashion industry, art galleries, restaurants, cafes, and shopping centers. Paris is a popular tourist destination and attracts millions of visitors every year.

Other LLM plugins

The other plugins run slower, but that might be because they are giving larger outputs.

  • MLC llama-2-7b. 26 seconds. Something weird in htop, it doesn’t look like it’s using any CPU?!
    Thank you for asking! The capital of France is Paris. I’m glad you asked, as it’s a beautiful and vibrant city that offers a lot of interesting places to visit and things to do. If you have any other questions or need further assistance, feel free to ask!
  • llama-cpp llama-2-7b-chat.ggmlv3.q8_0. 22 seconds.
    The capital of France is Paris. It is located in the northern central part of the country and is known for its iconic landmarks such as the Eiffel Tower, Notre-Dame Cathedral, and the Louvre Museum.
  • mpt-30b. 75 seconds.
    The capital of France is Paris. It is located in the northern central part of the country and is known for its famous landmarks such as the Eiffel Tower, the Louvre Museum, and the Notre-Dame Cathedral. With a population of over 2 million people, Paris is one of the most populous cities in Europe. It is also known for its art, fashion, cuisine, and cultural heritage, making it one of the most popular tourist destinations in the world.

Specialist output

These models seem to be giving some unique output, not general chat.

  • gpt4all Bert (ggml-all-MiniLM-L6-v2-f16). 0.8s. I think it’s not intended for direct use.
    !!!!!!!!!!!!!!!!!!!...
  • gpt4all starcoderbase-7b-ggml. 34s. One of several models specifically for generating code.
    def get_capital(country): ...
  • gp5rall markov. 2.4s. This is a simple Markov chain as a demo of how to write a plugin, not a serious tool for use.
    is the capital of france france the capital of france what is the capital of france the capital of france...

Daily usage

Now when I want to ask an AI a question I’ll simply do llm 'my question here'. No more thought than that required, answers in about 10 seconds depending on the complexity.

I went ahead and ran llm models default wizardLM-13B-Uncensored to pick a specific default model. Why that one? Simon’s notes say Wizard is the best choice and it ran fast enough for me. Not sure what all the “uncensored” means but that seemed like a novelty I could try that’s not available at the online services. I suspect it isn’t adding anything of value though.