<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>efemerisk blog</title>
<link href="https://blog.efemerisk.dk/"/>
<link rel="self" href="https://blog.efemerisk.dk/feed.xml"/>
<id>https://blog.efemerisk.dk/</id>
<updated>2026-11-26T00:00:00Z</updated>
<entry>
  <title>Exciting technology in search of a problem</title>
  <link href="https://blog.efemerisk.dk/exciting-technology-in-search-of-a-problem/"/>
  <id>https://blog.efemerisk.dk/exciting-technology-in-search-of-a-problem/</id>
  <updated>2026-11-26T00:00:00Z</updated>
  <summary>Dietary requirements in the free-text comment of a food order or table booking (up to 160 characters in my test data, Danish and English) can be identified with more than 90% accuracy in under 300 ms per comment, on an ordinary CPU with less than 3 GB of memory.</summary>
  <content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Dietary requirements in the free-text comment of a food order or table booking (up to 160 characters in my test data, Danish and English) can be identified with more than 90% accuracy in under 300 ms per comment, on an ordinary CPU with less than 3 GB of memory. It requires fine-tuning a small open-source model for the task (under 1B parameters, a text classifier rather than a chat LLM). The fine-tuning costs about $0.05 on &lt;a href=&quot;https://modal.com&quot;&gt;modal.com&lt;/a&gt;, or you can do it on a beefy laptop if you have the patience. Try it yourself at &lt;a href=&quot;https://kosthensyn.efemerisk.dk&quot;&gt;kosthensyn.efemerisk.dk&lt;/a&gt;. This is of course simplistic, so read the details below.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;AI is everywhere, but for most people, it is something in the cloud.&lt;/p&gt;
&lt;p&gt;I use Claude every day, and as long as I only need to share source code with it, everything is fine. If it is my own personal data, that is also OK. In a business context, it is complicated, even more so for a live stream of production data coming through your systems. Data privacy is probably the biggest concern. You might also be concerned about cost or latency.&lt;/p&gt;
&lt;p&gt;I have tried running some small self-hosted LLMs on laptops. It is not the same as using Claude or ChatGPT. For example, I once spent 5 minutes waiting for a 12B model thinking about whether &amp;ldquo;pull-up&amp;rdquo; in my prompt should be &amp;ldquo;pulse&amp;rdquo; instead. Claude answered the same prompt perfectly in 10 seconds. For some tasks, self-hosted models are great, like text recognition (OCR) and face recognition in photos or speech to text in your own language, especially when accuracy below 100% is acceptable. Generally, my experience is that if you want to use thinking mode for a self-hosted model of size &amp;gt;10B on your laptop, you should expect higher latency than what you are used to from the hosted providers. In some business contexts that is fine, for example when a user uploads a document and some background process extracts the content to a structured format before a professional case worker looks into the case. In other cases, it is not acceptable.&lt;/p&gt;
&lt;h2 id=&quot;decision-models&quot;&gt;Decision models&lt;a class=&quot;anchor&quot; href=&quot;#decision-models&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s when decision models showed up. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.typesafe.ai/api&quot;&gt;Jev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/jaredpalmer/kev&quot;&gt;Kev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/NandhaKishorM/laya&quot;&gt;Laya&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/strands-labs/strands-decider&quot;&gt;Strands-decider&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Jev is the one doing most of the marketing. My interpretation of the promise is that by limiting the output values to a small set (e.g. 20 values), even small models can make good decisions. To me, small models are interesting here because they open up the option of self-hosting the model, even on commodity hardware (no GPU needed), while still answering in a fraction of a second.&lt;/p&gt;
&lt;h2 id=&quot;finding-a-problem&quot;&gt;Finding a problem&lt;a class=&quot;anchor&quot; href=&quot;#finding-a-problem&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I recently had a good experience with a model that was specialized in speech to text for Danish. I thought it would be nice to try decision models on a concrete case and fine-tune or train them. I thought about a good application for such a decision model and ended up with these criteria:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it must be relatively high volume (not just 3 requests per week).&lt;/li&gt;
&lt;li&gt;data privacy is important, so self-hosting would make compliance easier compared to e.g. Claude.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I had a few cases in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;semantic search, e.g. on Shopify.&lt;/li&gt;
&lt;li&gt;sentiment analysis.&lt;/li&gt;
&lt;li&gt;classification of personal postings in my bank.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ultimately, I went with a problem that might not really exist. I decided to classify whether a free-form text contains information about dietary requirements, with the intention that this model could be used by online booking systems for fast food, table booking or conferences. Immediately, I thought to myself that these systems could just add a field to their form titled &amp;ldquo;Dietary requirements&amp;rdquo;. They could, but that would make my project useless, and as I see it, it would have the following shortcomings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it would give the user the expectation that their dietary requirement is actually fulfilled, which might not be easy to guarantee.&lt;/li&gt;
&lt;li&gt;it would add one extra field to the buying process (small hurdles add up for the end user, and you really want them to click the Buy button).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Moreover, the restaurant or catering staff could make sure to carefully read every free-form text message, but again (1) we should assume that humans make mistakes in these busy jobs, and (2) the staff might not understand the local language, like Danish.&lt;/p&gt;
&lt;h2 id=&quot;training-laya&quot;&gt;Training Laya&lt;a class=&quot;anchor&quot; href=&quot;#training-laya&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;So, I decided to try this out. Jev has closed weights, so I had to choose another project. I decided to try Laya first because the project encouraged training the model for the specific use case. For development, I used Claude Opus 5.5, and for training, I used modal.com to try out some cloud infrastructure for AI training and to keep my laptop fan quiet. I wrote up 5 examples of dietary requirements and asked Claude to generate 1000 more. Probably bad quality data, but a good place to start in my opinion. The test comments definitely had a lot of holes, and I iterated on the data during this experiment. The test data still has many shortcomings, and for a model to perform well, I would always suggest training the model on a real, labelled dataset for the concrete business if allowed.&lt;/p&gt;
&lt;p&gt;The first experiment was to contrast the Laya base model with a model that was trained for this specific task, of course keeping training and test data separate. Some facts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;training time and cost on modal.com: 3 epochs on the 2,315 training comments (Laya sets 231 of them aside to calibrate its scores) took 224 seconds on an NVIDIA T4. The whole job, including downloading the model and scoring before and after training, used 273 GPU seconds, which is about $0.05 at Modal&amp;rsquo;s T4 price ($0.59 per hour).&lt;/li&gt;
&lt;li&gt;base model performance: it said yes to every single comment, so it was useless for this task. On paper, that is still 65.9% accuracy on the test data (1,547 comments) and 57.3% on the training data, simply because that is the share of comments that do mention a dietary need.&lt;/li&gt;
&lt;li&gt;trained model performance: 94.2% accuracy on the test data (90 errors) and 98.7% on the training data (31 errors).&lt;/li&gt;
&lt;li&gt;Laya performance characteristics on consumer hardware: on my M3 Mac with 16 GB, CPU only and one comment at a time, 100 test comments took a median of 81 ms each (95th percentile 88 ms). Loading the model takes 2 to 6 seconds.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think it is worth pausing here. The model improved significantly, from saying yes every time to 94% accuracy on the test data. Since this was my first experience with training AI, I was quite happy and I encourage you to try training a small model for something – for the fun of it!&lt;/p&gt;
&lt;h2 id=&quot;bigger-models&quot;&gt;Bigger models&lt;a class=&quot;anchor&quot; href=&quot;#bigger-models&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Anyway, I then tried some bigger models:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Kev 0.8B and Kev 4B, fine-tuned on the same comments with Kev&amp;rsquo;s own training recipe&lt;/li&gt;
&lt;li&gt;strands-decider 2B, as it is, without any training for the specific task&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Results on an earlier version of my test data (880 comments):&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;model&lt;/th&gt;
&lt;th&gt;errors (of 880)&lt;/th&gt;
&lt;th&gt;latency per comment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Laya, fine-tuned&lt;/td&gt;
&lt;td&gt;79&lt;/td&gt;
&lt;td&gt;about 80 ms on a Mac CPU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;strands-decider 2B, no training&lt;/td&gt;
&lt;td&gt;82&lt;/td&gt;
&lt;td&gt;240–330 ms on the Mac&amp;rsquo;s GPU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kev 0.8B, fine-tuned&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;2 s on 2 CPU cores, 166 ms on a cloud GPU (L4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kev 4B, fine-tuned&lt;/td&gt;
&lt;td&gt;26&lt;/td&gt;
&lt;td&gt;not measured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;for context:&lt;/em&gt; Claude Haiku 5.5, no training&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;cloud only, not measured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;for context:&lt;/em&gt; a simple regex (allerg, intol, ache and typos)&lt;/td&gt;
&lt;td&gt;192&lt;/td&gt;
&lt;td&gt;under 0.01 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;All of them had similar or better accuracy than my task-trained Laya model. The problem was then latency and resource requirements, e.g. a dedicated GPU.&lt;/p&gt;
&lt;h2 id=&quot;a-plain-encoder-instead&quot;&gt;A plain encoder instead&lt;a class=&quot;anchor&quot; href=&quot;#a-plain-encoder-instead&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In the end, I asked Claude if it could suggest another approach and it suggested &lt;a href=&quot;https://huggingface.co/intfloat/multilingual-e5-large&quot;&gt;Multilingual-E5-large&lt;/a&gt; with training of that.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;training time and cost on modal.com: 4 epochs on the same 2,315 training comments took 91 seconds on an NVIDIA A10, about $0.03 at Modal&amp;rsquo;s A10 price ($1.10 per hour).&lt;/li&gt;
&lt;li&gt;base model performance: not applicable. E5 is an embedding model, so it gets a new classification head that only means something after training.&lt;/li&gt;
&lt;li&gt;trained model performance: 96.3% accuracy on the test data (58 errors) and 100% on the training data (0 errors).&lt;/li&gt;
&lt;li&gt;performance on consumer hardware: on the same M3 Mac, CPU only and one comment at a time, a median of 82 ms per comment (95th percentile 92 ms). Limited to 2 CPU threads, like a small VPS, it was 72 ms (95th percentile 83 ms).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Side by side on the dietary-needs data:&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Laya&lt;/th&gt;
&lt;th&gt;Multilingual-E5-large&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;training on modal.com&lt;/td&gt;
&lt;td&gt;224 s on a T4, about $0.04&lt;/td&gt;
&lt;td&gt;91 s on an A10, about $0.03&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;accuracy on test data (1,547 comments)&lt;/td&gt;
&lt;td&gt;94.2% (90 errors)&lt;/td&gt;
&lt;td&gt;96.3% (58 errors)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;accuracy on training data (2,315 comments)&lt;/td&gt;
&lt;td&gt;98.7%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;median latency on a Mac CPU&lt;/td&gt;
&lt;td&gt;81 ms&lt;/td&gt;
&lt;td&gt;82 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;For context, here are an upper and a lower bound on the same 1,547 test comments. Claude Haiku 5.5 reads the comments with the same instructions and no training. It does not fit the use case, because it runs in the cloud. The two regular expressions are what you could write without any model: a simple one with a handful of word stems (&amp;ldquo;allerg&amp;rdquo;, &amp;ldquo;intol&amp;rdquo;, &amp;ldquo;ache&amp;rdquo;, &amp;ldquo;tåle&amp;rdquo; and common typos), and a clever one that I had Claude write from the training comments (allergies, symptoms followed by a food, diets, &amp;ldquo;uden X&amp;rdquo; / &amp;ldquo;no X&amp;rdquo; / &amp;ldquo;go easy on X&amp;rdquo;, minus look-alikes such as &amp;ldquo;no allergies&amp;rdquo; and &amp;ldquo;extra X&amp;rdquo;).&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;errors (of 1,547)&lt;/th&gt;
&lt;th&gt;accuracy on test data&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Haiku 5.5, no training&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;99.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multilingual-E5-large, fine-tuned&lt;/td&gt;
&lt;td&gt;58&lt;/td&gt;
&lt;td&gt;96.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Laya, fine-tuned&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;94.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clever regex, written from the training data&lt;/td&gt;
&lt;td&gt;208&lt;/td&gt;
&lt;td&gt;86.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;saying yes to every comment&lt;/td&gt;
&lt;td&gt;527&lt;/td&gt;
&lt;td&gt;65.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;simple regex&lt;/td&gt;
&lt;td&gt;618&lt;/td&gt;
&lt;td&gt;60.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;The simple regex is worse than saying yes every time. The clever regex made only 42 errors on the training comments it was written from, but 208 on the test data, so it overfits just like the models do.&lt;/p&gt;
&lt;p&gt;The model clearly overfits to the training data. In general, that is a problem, but in this concrete use case of free-form comments on e.g. food orders, I think it is actually OK, especially if you can be satisfied with around 90% accuracy.&lt;/p&gt;
&lt;p&gt;On the same 880 comments as in the table above, the fine-tuned E5-large made 46 errors: better than Kev 0.8B, but not as good as Kev 4B. So this model gets close to the bigger models with much lower latency, and it can run on the Virtual Private Server you probably already use. The demo at &lt;a href=&quot;https://kosthensyn.efemerisk.dk&quot;&gt;kosthensyn.efemerisk.dk&lt;/a&gt; runs the fine-tuned E5-large in Danish and English on a CPU-only server that costs about €6 a month.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;a class=&quot;anchor&quot; href=&quot;#wrapping-up&quot; title=&quot;Link to this section&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It was a fun experience to go through this, and I learned about training small models and also about the domain along the way. For example, I switched from trying to identify allergies to identifying dietary requirements, which I believe is more relevant to the domain and easier for the models to learn.&lt;/p&gt;
&lt;p&gt;Identifying dietary requirements is really a concrete case of trying to map free text onto a fixed data model. The same approach could be taken for many other web forms with a free-text input field. If we limit ourselves to small models, it will require fine-tuning on data from the business itself to achieve high accuracy.&lt;/p&gt;
&lt;p&gt;In this small case study, I have focused on deciding yes or no for dietary requirements. I think that is a good fit for this use case, because once a comment has been brought to the staff&amp;rsquo;s attention, a human can easily and quickly read it and find the actual requirement. Still, it would be interesting to also try to extract the requirement by machine. For example, we could limit ourselves to a list of the 15 most common requirements plus an &amp;ldquo;other&amp;rdquo; category, so the model would still pick from a fixed set of values.&lt;/p&gt;
&lt;p&gt;You can try it yourself at &lt;a href=&quot;https://kosthensyn.efemerisk.dk&quot;&gt;kosthensyn.efemerisk.dk&lt;/a&gt;. I will reach out to some food delivery or table booking platforms to see if they are curious. If you are curious about training small models or some of the use cases above, reach out to me by email at &lt;a href=&quot;mailto:bla@efemerisk.dk&quot;&gt;bla@efemerisk.dk&lt;/a&gt;.&lt;/p&gt;</content>
</entry>
</feed>
