<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: jeremy-howard</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/jeremy-howard.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2025-04-05T22:47:58+00:00</updated><author><name>Simon Willison</name></author><entry><title>Initial impressions of Llama 4</title><link href="https://simonwillison.net/2025/Apr/5/llama-4-notes/#atom-tag" rel="alternate"/><published>2025-04-05T22:47:58+00:00</published><updated>2025-04-05T22:47:58+00:00</updated><id>https://simonwillison.net/2025/Apr/5/llama-4-notes/#atom-tag</id><summary type="html">
    &lt;p&gt;Dropping a model release as significant as Llama 4 on a weekend is plain unfair! So far the best place to learn about the new model family is &lt;a href="https://ai.meta.com/blog/llama-4-multimodal-intelligence/"&gt;this post on the Meta AI blog&lt;/a&gt;. They've released two new models today: Llama 4 Maverick is a 400B model (128 experts, 17B active parameters), text and image input with a 1 million token context length. Llama 4 Scout is 109B total parameters (16 experts, 17B active), also multi-modal and with a claimed 10 million token context length - an industry first.&lt;/p&gt;

&lt;p&gt;They also describe Llama 4 Behemoth, a not-yet-released "288 billion active parameter model with 16 experts that is our most powerful yet and among the world’s smartest LLMs". Behemoth has 2 trillion parameters total and was used to train both Scout and Maverick.&lt;/p&gt;
&lt;p&gt;No news yet on a Llama reasoning model beyond &lt;a href="https://www.llama.com/llama4-reasoning-is-coming/"&gt;this coming soon page&lt;/a&gt; with a looping video of an academic-looking llama.&lt;/p&gt;

&lt;p id="lmarena"&gt;Llama 4 Maverick is now sat in second place on &lt;a href="https://lmarena.ai/?leaderboard"&gt;the LM Arena leaderboard&lt;/a&gt;, just behind Gemini 2.5 Pro. &lt;em&gt;&lt;strong&gt;Update&lt;/strong&gt;: It turns out that's not the same model as the Maverick they released - I missed that their announcement says "Llama 4 Maverick offers a best-in-class performance to cost ratio with an experimental chat version scoring ELO of 1417 on LMArena."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can try them out using the chat interface from OpenRouter (or through the OpenRouter API) for &lt;a href="https://openrouter.ai/meta-llama/llama-4-scout"&gt;Llama 4 Scout&lt;/a&gt; and &lt;a href="https://openrouter.ai/meta-llama/llama-4-maverick"&gt;Llama 4 Maverick&lt;/a&gt;. OpenRouter are proxying through to &lt;a href="https://console.groq.com/docs/models"&gt;Groq&lt;/a&gt;, &lt;a href="https://fireworks.ai/models"&gt;Fireworks&lt;/a&gt; and &lt;a href="https://docs.together.ai/docs/serverless-models"&gt;Together&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Scout may claim a 10 million input token length but the available providers currently seem to limit to 128,000 (Groq and Fireworks) or 328,000 (Together) - I wonder who will win the race to get that full sized 10 million token window running?&lt;/p&gt;
&lt;p&gt;Llama 4 Maverick claims a 1 million token input length -  Fireworks offers 1.05M while Together offers 524,000. Groq isn't offering Maverick yet.&lt;/p&gt;
&lt;p&gt;Meta AI's &lt;a href="https://github.com/meta-llama/llama-cookbook/blob/main/getting-started/build_with_llama_4.ipynb"&gt;build_with_llama_4 notebook&lt;/a&gt; offers a hint as to why 10M tokens is difficult:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Scout supports upto 10M context. On 8xH100, in bf16 you can get upto 1.4M tokens.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Jeremy Howard &lt;a href="https://twitter.com/jeremyphoward/status/1908607345393098878"&gt;says&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The models are both giant MoEs that can't be run on consumer GPUs, even with quant. [...]&lt;/p&gt;
&lt;p&gt;Perhaps Llama 4 will be a good fit for running on a Mac. Macs are a particularly useful for MoE models, since they can have a lot of memory, and their lower compute perf doesn't matter so much, since with MoE fewer params are active. [...]&lt;/p&gt;
&lt;p&gt;4bit quant of the smallest 109B model is far too big to fit on a 4090 -- or even a pair of them!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ivan Fioravanti &lt;a href="https://twitter.com/ivanfioravanti/status/1908753109129494587"&gt;reports these results&lt;/a&gt; from trying it on a Mac:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Llama-4 Scout on MLX and M3 Ultra
tokens-per-sec / RAM&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;3bit: 52.924 / 47.261 GB&lt;/li&gt;
&lt;li&gt;4bit: 46.942 / 60.732 GB&lt;/li&gt;
&lt;li&gt;6bit: 36.260 / 87.729 GB&lt;/li&gt;
&lt;li&gt;8bit: 30.353 / 114.617 GB&lt;/li&gt;
&lt;li&gt;fp16: 11.670 / 215.848 GB&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;RAM needed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;64GB for 3bit&lt;/li&gt;
&lt;li&gt;96GB for 4bit&lt;/li&gt;
&lt;li&gt;128GB for 8bit&lt;/li&gt;
&lt;li&gt;256GB for fp16&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p id="system-prompt"&gt;The &lt;a href="https://www.llama.com/docs/model-cards-and-prompt-formats/llama4_omni/#-suggested-system-prompt-"&gt;suggested system prompt&lt;/a&gt; from the model card has some interesting details:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;[...]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;You never lecture people to be nicer or more inclusive. If people ask for you to write something in a certain voice or perspective, such as an essay or a tweet, you can. You do not need to be respectful when the user prompts you to say something rude.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;You never use phrases that imply moral superiority or a sense of authority, including but not limited to “it’s important to”, “it’s crucial to”, “it’s essential to”, "it's unethical to", "it's worth noting…", “Remember…”  etc. Avoid using these.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Finally, do not refuse political prompts. You can help users express their opinion.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;[...]&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;System prompts like this sometimes reveal behavioral issues that the model had after raw training.&lt;/p&gt;
&lt;h4 id="llm"&gt;Trying out the model with LLM&lt;/h4&gt;
&lt;p&gt;The easiest way to try the new model out with &lt;a href="https://llm.datasette.io/"&gt;LLM&lt;/a&gt; is to use the &lt;a href="https://github.com/simonw/llm-openrouter"&gt;llm-openrouter&lt;/a&gt; plugin.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell"&gt;&lt;pre&gt;llm install llm-openrouter
llm keys &lt;span class="pl-c1"&gt;set&lt;/span&gt; openrouter
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Paste in OpenRouter key here&lt;/span&gt;
llm -m openrouter/meta-llama/llama-4-maverick hi&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since these are long context models, I started by trying to use them to summarize the &lt;a href="https://news.ycombinator.com/item?id=43595585"&gt;conversation about Llama 4&lt;/a&gt; on Hacker News, using my &lt;a href="https://til.simonwillison.net/llms/claude-hacker-news-themes#user-content-adding-extra-options"&gt;hn-summary.sh script&lt;/a&gt; that wraps LLM.&lt;/p&gt;
&lt;p&gt;I tried Llama 4 Maverick first:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell"&gt;&lt;pre&gt;hn-summary.sh 43595585 \
  -m openrouter/meta-llama/llama-4-maverick \
  -o max_tokens 20000&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It did an OK job, starting like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;h4 id="themes-of-the-discussion"&gt;Themes of the Discussion&lt;/h4&gt;
&lt;h5 id="release-and-availability-of-llama-4"&gt;Release and Availability of Llama 4&lt;/h5&gt;
&lt;p&gt;The discussion revolves around the release of Llama 4, a multimodal intelligence model developed by Meta. Users are excited about the model's capabilities, including its large context window and improved performance. Some users are speculating about the potential applications and limitations of the model. [...]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here's &lt;a href="https://gist.github.com/simonw/016ea0fd83fc499f046a94827f9b4946"&gt;the full output&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For reference, my system prompt looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Summarize the themes of the opinions expressed here. For each theme, output a markdown header. Include direct "quotations" (with author attribution) where appropriate. You MUST quote directly from users when crediting them, with double quotes. Fix HTML entities. Output markdown. Go long. Include a section of quotes that illustrate opinions uncommon in the rest of the piece&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I then tried it with Llama 4 Scout via OpenRouter and got complete junk output for some reason:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hn-summary.sh 43595585 \
  -m openrouter/meta-llama/llama-4-scout \
  -o max_tokens 20000
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://gist.github.com/simonw/d01cc991d478939e87487d362a8f881f"&gt;Full output&lt;/a&gt;. It starts like this and then continues for the full 20,000 tokens:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The discussion here is about another conversation that was uttered.)&lt;/p&gt;
&lt;p&gt;Here are the results.)&lt;/p&gt;
&lt;p&gt;The conversation between two groups, and I have the same questions on the contrary than those that are also seen in a model."). The fact that I see a lot of interest here.)&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;The reason) The reason) The reason &lt;em&gt;(loops until it runs out of tokens)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This looks broken. I was using OpenRouter so it's possible I got routed to a broken instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 7th April 2025&lt;/strong&gt;: Meta AI's &lt;a href="https://twitter.com/ahmad_al_dahle/status/1909302532306092107"&gt;Ahmed Al-Dahle&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[...] we're also hearing some reports of mixed quality across different services. Since we dropped the models as soon as they were ready, we expect it'll take several days for all the public implementations to get dialed in. We'll keep working through our bug fixes and onboarding partners.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I later managed to run the prompt directly through Groq (with the &lt;a href="https://github.com/angerman/llm-groq"&gt;llm-groq&lt;/a&gt; plugin) - but that had a 2048 limit on output size for some reason:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hn-summary.sh 43595585 \
  -m groq/meta-llama/llama-4-scout-17b-16e-instruct \
  -o max_tokens 2048
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here's &lt;a href="https://gist.github.com/simonw/a205c5fc131a1d4e9cd6c432a07feedb"&gt;the full result&lt;/a&gt;. It followed my instructions but was &lt;em&gt;very&lt;/em&gt; short - just 630 tokens of output.&lt;/p&gt;
&lt;p&gt;For comparison, here's &lt;a href="https://gist.github.com/simonw/f21ecc7fb2aa13ff682d4ffa11ddcbfd"&gt;the same thing&lt;/a&gt; run against Gemini 2.5 Pro. Gemini's results was &lt;em&gt;massively&lt;/em&gt; better, producing 5,584 output tokens (it spent an additional 2,667 tokens on "thinking").&lt;/p&gt;
&lt;p&gt;I'm not sure how much to judge Llama 4 by these results to be honest - the model has only been out for a few hours and it's quite possible that the providers I've tried running again aren't yet optimally configured for this kind of long-context prompt.&lt;/p&gt;
&lt;h4 id="my-hopes-for-llama-4"&gt;My hopes for Llama 4&lt;/h4&gt;
&lt;p&gt;I'm hoping that Llama 4 plays out in a similar way to Llama 3.&lt;/p&gt;
&lt;p&gt;The first Llama 3 models released were 8B and 70B, &lt;a href="https://ai.meta.com/blog/meta-llama-3/"&gt;last April&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Llama 3.1 followed &lt;a href="https://ai.meta.com/blog/meta-llama-3-1/"&gt;in July&lt;/a&gt; at 8B, 70B, and 405B. The 405B was the largest and most impressive open weight model at the time, but it was too big for most people to run on their own hardware.&lt;/p&gt;
&lt;p&gt;Llama 3.2 &lt;a href="https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/"&gt;in September&lt;/a&gt; is where things got really interesting: 1B, 3B, 11B and 90B. The 1B and 3B models both work on my iPhone, and are surprisingly capable! The 11B and 90B models were the first Llamas to support vision, and the 11B &lt;a href="https://simonwillison.net/2024/Sep/25/llama-32/"&gt;ran on my Mac&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then Llama 3.3 landed in December with a 70B model that &lt;a href="https://simonwillison.net/2024/Dec/9/llama-33-70b/"&gt;I wrote about as a GPT-4 class model that ran on my Mac&lt;/a&gt;. It claimed performance similar to the earlier Llama 3.1 405B!&lt;/p&gt;
&lt;p&gt;Today's Llama 4 models are 109B and 400B, both of which were trained with the help of the so-far unreleased 2T Llama 4 Behemoth.&lt;/p&gt;
&lt;p&gt;My hope is that we'll see a whole family of Llama 4 models at varying sizes, following the pattern of Llama 3. I'm particularly excited to see if they produce an improved ~3B model that runs on my phone. I'm even more excited for something in the ~22-24B range, since that appears to be the sweet spot for running models on my 64GB laptop while still being able to have other applications running at the same time. Mistral Small 3.1 is a 24B model and is &lt;a href="https://simonwillison.net/2025/Mar/17/mistral-small-31/"&gt;absolutely superb&lt;/a&gt;.&lt;/p&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llama"&gt;llama&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/gemini"&gt;gemini&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/vision-llms"&gt;vision-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/groq"&gt;groq&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/meta"&gt;meta&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mlx"&gt;mlx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/long-context"&gt;long-context&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm-release"&gt;llm-release&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/openrouter"&gt;openrouter&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/chatbot-arena"&gt;chatbot-arena&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="ai"/><category term="generative-ai"/><category term="llama"/><category term="llms"/><category term="jeremy-howard"/><category term="llm"/><category term="gemini"/><category term="vision-llms"/><category term="groq"/><category term="meta"/><category term="mlx"/><category term="long-context"/><category term="llm-release"/><category term="openrouter"/><category term="chatbot-arena"/></entry><entry><title>Finally, a replacement for BERT: Introducing ModernBERT</title><link href="https://simonwillison.net/2024/Dec/24/modernbert/#atom-tag" rel="alternate"/><published>2024-12-24T06:21:29+00:00</published><updated>2024-12-24T06:21:29+00:00</updated><id>https://simonwillison.net/2024/Dec/24/modernbert/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.answer.ai/posts/2024-12-19-modernbert.html"&gt;Finally, a replacement for BERT: Introducing ModernBERT&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;a href="https://en.wikipedia.org/wiki/BERT_(language_model)"&gt;BERT&lt;/a&gt; was an early language model released by Google in October 2018. Unlike modern LLMs it wasn't designed for generating text. BERT was trained for masked token prediction and was generally applied to problems like Named Entity Recognition or Sentiment Analysis. BERT also wasn't very useful on its own - most applications required you to fine-tune a model on top of it.&lt;/p&gt;
&lt;p&gt;In exploring BERT I decided to try out &lt;a href="https://huggingface.co/dslim/distilbert-NER"&gt;dslim/distilbert-NER&lt;/a&gt;, a popular Named Entity Recognition model fine-tuned on top of DistilBERT (a smaller distilled version of the original BERT model). &lt;a href="https://til.simonwillison.net/llms/bert-ner"&gt;Here are my notes&lt;/a&gt; on running that using &lt;code&gt;uv run&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Jeremy Howard's &lt;a href="https://www.answer.ai/"&gt;Answer.AI&lt;/a&gt; research group, &lt;a href="https://www.lighton.ai/"&gt;LightOn&lt;/a&gt; and friends supported the development of ModernBERT, a brand new BERT-style model that applies many enhancements from the past six years of advances in this space.&lt;/p&gt;
&lt;p&gt;While BERT was trained on 3.3 billion tokens, producing 110 million and 340 million parameter models, ModernBERT trained on 2 trillion tokens, resulting in 140 million and 395 million parameter models. The parameter count hasn't increased much because it's designed to run on lower-end hardware. It has a 8192 token context length, a significant improvement on BERT's 512.&lt;/p&gt;
&lt;p&gt;I was able to run one of the demos from the announcement post using &lt;code&gt;uv run&lt;/code&gt; like this (I'm not sure why I had to use &lt;code&gt;numpy&amp;lt;2.0&lt;/code&gt; but without that I got an error about &lt;code&gt;cannot import name 'ComplexWarning' from 'numpy.core.numeric'&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight highlight-source-shell"&gt;&lt;pre&gt;uv run --with &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;numpy&amp;lt;2.0&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt; --with torch --with &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;git+https://github.com/huggingface/transformers.git&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt; python&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then this Python:&lt;/p&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-s1"&gt;torch&lt;/span&gt;
&lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s1"&gt;transformers&lt;/span&gt; &lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-s1"&gt;pipeline&lt;/span&gt;
&lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s1"&gt;pprint&lt;/span&gt; &lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-s1"&gt;pprint&lt;/span&gt;
&lt;span class="pl-s1"&gt;pipe&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;pipeline&lt;/span&gt;(
    &lt;span class="pl-s"&gt;"fill-mask"&lt;/span&gt;,
    &lt;span class="pl-s1"&gt;model&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;"answerdotai/ModernBERT-base"&lt;/span&gt;,
    &lt;span class="pl-s1"&gt;torch_dtype&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-s1"&gt;torch&lt;/span&gt;.&lt;span class="pl-c1"&gt;bfloat16&lt;/span&gt;,
)
&lt;span class="pl-s1"&gt;input_text&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s"&gt;"He walked to the [MASK]."&lt;/span&gt;
&lt;span class="pl-s1"&gt;results&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;pipe&lt;/span&gt;(&lt;span class="pl-s1"&gt;input_text&lt;/span&gt;)
&lt;span class="pl-en"&gt;pprint&lt;/span&gt;(&lt;span class="pl-s1"&gt;results&lt;/span&gt;)&lt;/pre&gt;
&lt;p&gt;Which downloaded 573MB to &lt;code&gt;~/.cache/huggingface/hub/models--answerdotai--ModernBERT-base&lt;/code&gt; and output:&lt;/p&gt;
&lt;pre&gt;[{&lt;span class="pl-s"&gt;'score'&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.11669921875&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'sequence'&lt;/span&gt;: &lt;span class="pl-s"&gt;'He walked to the door.'&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token'&lt;/span&gt;: &lt;span class="pl-c1"&gt;3369&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token_str'&lt;/span&gt;: &lt;span class="pl-s"&gt;' door'&lt;/span&gt;},
 {&lt;span class="pl-s"&gt;'score'&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.037841796875&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'sequence'&lt;/span&gt;: &lt;span class="pl-s"&gt;'He walked to the office.'&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token'&lt;/span&gt;: &lt;span class="pl-c1"&gt;3906&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token_str'&lt;/span&gt;: &lt;span class="pl-s"&gt;' office'&lt;/span&gt;},
 {&lt;span class="pl-s"&gt;'score'&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.0277099609375&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'sequence'&lt;/span&gt;: &lt;span class="pl-s"&gt;'He walked to the library.'&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token'&lt;/span&gt;: &lt;span class="pl-c1"&gt;6335&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token_str'&lt;/span&gt;: &lt;span class="pl-s"&gt;' library'&lt;/span&gt;},
 {&lt;span class="pl-s"&gt;'score'&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.0216064453125&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'sequence'&lt;/span&gt;: &lt;span class="pl-s"&gt;'He walked to the gate.'&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token'&lt;/span&gt;: &lt;span class="pl-c1"&gt;7394&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token_str'&lt;/span&gt;: &lt;span class="pl-s"&gt;' gate'&lt;/span&gt;},
 {&lt;span class="pl-s"&gt;'score'&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.020263671875&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'sequence'&lt;/span&gt;: &lt;span class="pl-s"&gt;'He walked to the window.'&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token'&lt;/span&gt;: &lt;span class="pl-c1"&gt;3497&lt;/span&gt;,
  &lt;span class="pl-s"&gt;'token_str'&lt;/span&gt;: &lt;span class="pl-s"&gt;' window'&lt;/span&gt;}]&lt;/pre&gt;

&lt;p&gt;I'm looking forward to trying out models that use ModernBERT as their base. The model release is accompanied by a paper (&lt;a href="https://arxiv.org/abs/2412.13663"&gt;Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference&lt;/a&gt;) and &lt;a href="https://huggingface.co/docs/transformers/main/en/model_doc/modernbert"&gt;new documentation&lt;/a&gt; for using it with the Transformers library.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://bsky.app/profile/benjaminwarner.dev/post/3ldur45oz322b"&gt;@benjaminwarner.dev&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/bert"&gt;bert&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nlp"&gt;nlp&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/transformers"&gt;transformers&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/hugging-face"&gt;hugging-face&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/uv"&gt;uv&lt;/a&gt;&lt;/p&gt;



</summary><category term="bert"/><category term="nlp"/><category term="python"/><category term="transformers"/><category term="ai"/><category term="jeremy-howard"/><category term="hugging-face"/><category term="uv"/></entry><entry><title>Quoting fast.ai Discord Server</title><link href="https://simonwillison.net/2024/Nov/9/fastai-discord-server/#atom-tag" rel="alternate"/><published>2024-11-09T06:59:02+00:00</published><updated>2024-11-09T06:59:02+00:00</updated><id>https://simonwillison.net/2024/Nov/9/fastai-discord-server/#atom-tag</id><summary type="html">
    &lt;blockquote cite="https://twitter.com/jeremyphoward/status/1855093111929946582"&gt;&lt;p&gt;This is a very friendly and supportive place where you are surrounded by peers - we all want to help each other succeed. The golden rule of this server is:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; ever try to impress anyone here with your knowledge! Instead try to impress folks here with your &lt;em&gt;desire to learn&lt;/em&gt;, and &lt;em&gt;desire to help others learn&lt;/em&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="https://twitter.com/jeremyphoward/status/1855093111929946582"&gt;fast.ai Discord Server&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/community"&gt;community&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fastai"&gt;fastai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/discord"&gt;discord&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="community"/><category term="fastai"/><category term="discord"/><category term="jeremy-howard"/></entry><entry><title>Quoting Jeremy Howard</title><link href="https://simonwillison.net/2024/Jun/29/jeremy-howard/#atom-tag" rel="alternate"/><published>2024-06-29T22:52:41+00:00</published><updated>2024-06-29T22:52:41+00:00</updated><id>https://simonwillison.net/2024/Jun/29/jeremy-howard/#atom-tag</id><summary type="html">
    &lt;blockquote cite="https://twitter.com/jeremyphoward/status/1807162709664047144"&gt;&lt;p&gt;Absolutely any time I try to explore something even slightly against commonly accepted beliefs, LLMs &lt;em&gt;always&lt;/em&gt; just rehash the commonly accepted beliefs.&lt;/p&gt;
&lt;p&gt;As a researcher, I find this behaviour worse than unhelpful. It gives the mistaken impression that there's nothing to explore.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="https://twitter.com/jeremyphoward/status/1807162709664047144"&gt;Jeremy Howard&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="llms"/><category term="jeremy-howard"/></entry><entry><title>fastlite</title><link href="https://simonwillison.net/2024/May/27/fastlite/#atom-tag" rel="alternate"/><published>2024-05-27T21:14:01+00:00</published><updated>2024-05-27T21:14:01+00:00</updated><id>https://simonwillison.net/2024/May/27/fastlite/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://answerdotai.github.io/fastlite/"&gt;fastlite&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
New Python library from Jeremy Howard that adds some neat utility functions and syntactic sugar to my &lt;a href="https://sqlite-utils.datasette.io/"&gt;sqlite-utils&lt;/a&gt; Python library, specifically for interactive use in Jupyter notebooks.&lt;/p&gt;
&lt;p&gt;The autocomplete support through newly exposed dynamic properties is particularly neat, as is the &lt;code&gt;diagram(db.tables)&lt;/code&gt; utility for rendering a graphviz diagram showing foreign key relationships between all of the tables.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/jeremyphoward/status/1795170005367050655"&gt;@jeremyphoward&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jupyter"&gt;jupyter&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite-utils"&gt;sqlite-utils&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="python"/><category term="sqlite"/><category term="jupyter"/><category term="sqlite-utils"/><category term="jeremy-howard"/></entry><entry><title>Quoting Jeremy Howard</title><link href="https://simonwillison.net/2024/Apr/29/jeremy-howard/#atom-tag" rel="alternate"/><published>2024-04-29T16:04:01+00:00</published><updated>2024-04-29T16:04:01+00:00</updated><id>https://simonwillison.net/2024/Apr/29/jeremy-howard/#atom-tag</id><summary type="html">
    &lt;blockquote cite="https://www.answer.ai/posts/2024-04-29-sb1047.html"&gt;&lt;p&gt;The creator of a model can not ensure that a model is never used to do something harmful – any more so that the developer of a web browser, calculator, or word processor could. Placing liability on the creators of general purpose tools like these mean that, in practice, such tools can not be created at all, except by big businesses with well funded legal teams.&lt;/p&gt;
&lt;p&gt;[...] Instead of regulating the development of AI models, the focus should be on regulating their applications, particularly those that pose high risks to public safety and security. Regulate the use of AI in high-risk areas such as healthcare, criminal justice, and critical infrastructure, where the potential for harm is greatest, would ensure accountability for harmful use, whilst allowing for the continued advancement of AI technology.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="https://www.answer.ai/posts/2024-04-29-sb1047.html"&gt;Jeremy Howard&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ethics"&gt;ethics&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai-ethics"&gt;ai-ethics&lt;/a&gt;&lt;/p&gt;



</summary><category term="ethics"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="jeremy-howard"/><category term="ai-ethics"/></entry><entry><title>You can now train a 70b language model at home</title><link href="https://simonwillison.net/2024/Mar/8/you-can-now-train-a-70b-language-model-at-home/#atom-tag" rel="alternate"/><published>2024-03-08T10:47:53+00:00</published><updated>2024-03-08T10:47:53+00:00</updated><id>https://simonwillison.net/2024/Mar/8/you-can-now-train-a-70b-language-model-at-home/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.answer.ai/posts/2024-03-06-fsdp-qlora.html"&gt;You can now train a 70b language model at home&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Jeremy Howard and team: “Today, we’re releasing Answer.AI’s first project: a fully open source system that, for the first time, can efficiently train a 70b large language model on a regular desktop computer with two or more standard gaming GPUs (RTX 3090 or 4090).”&lt;/p&gt;

&lt;p&gt;This is about fine-tuning an existing model, not necessarily training one from scratch.&lt;/p&gt;

&lt;p&gt;There are two tricks at play here. The first is QLoRA, which can be used to train quantized models despite the reduced precision usually preventing gradient descent from working correctly.&lt;/p&gt;

&lt;p&gt;QLoRA can bring the memory requirements for a 70b model down to 35GB, but gaming GPUs aren’t quite that big. The second trick is Meta’s Fully Sharded Data Parallel or FSDP library, which can shard a model across GPUs. Two consumer 24GB GPUs can then handle the 70b training run.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/jeremyphoward/status/1765868543235805232"&gt;@jeremyphoward&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/gpus"&gt;gpus&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="jeremy-howard"/><category term="gpus"/></entry><entry><title>Getting Started With CUDA for Python Programmers</title><link href="https://simonwillison.net/2024/Jan/29/getting-started-with-cuda-for-python-programmers/#atom-tag" rel="alternate"/><published>2024-01-29T21:23:57+00:00</published><updated>2024-01-29T21:23:57+00:00</updated><id>https://simonwillison.net/2024/Jan/29/getting-started-with-cuda-for-python-programmers/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/watch?v=nOxKexn3iBo"&gt;Getting Started With CUDA for Python Programmers&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
if, like me, you’ve avoided CUDA programming (writing efficient code that runs on NVIGIA GPUs) in the past, Jeremy Howard has a new 1hr17m video tutorial that demystifies the basics. The code is all run using PyTorch in notebooks running on Google Colab, and it starts with a very clear demonstration of how to convert a RGB image to black and white.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/jeremyphoward/status/1752071227228008471"&gt;@jeremyphoward&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pytorch"&gt;pytorch&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/gpus"&gt;gpus&lt;/a&gt;&lt;/p&gt;



</summary><category term="python"/><category term="ai"/><category term="pytorch"/><category term="jeremy-howard"/><category term="gpus"/></entry><entry><title>Quoting Jeremy Howard</title><link href="https://simonwillison.net/2023/Dec/1/jeremy-howard/#atom-tag" rel="alternate"/><published>2023-12-01T02:49:00+00:00</published><updated>2023-12-01T02:49:00+00:00</updated><id>https://simonwillison.net/2023/Dec/1/jeremy-howard/#atom-tag</id><summary type="html">
    &lt;blockquote cite="https://www.youtube.com/live/6LXw2beprGI?si=I2JEqIccboFRou0K&amp;amp;t=1526"&gt;&lt;p&gt;So something everybody I think pretty much agrees on, including Sam Altman, including Yann LeCun, is LLMs aren't going to make it. The current LLMs are not a path to ASI. They're getting more and more expensive, they're getting more and more slow, and the more we use them, the more we realize their limitations.&lt;/p&gt;
&lt;p&gt;We're also getting better at taking advantage of them, and they're super cool and helpful, but they appear to be behaving as extremely flexible, fuzzy, compressed search engines, which when you have enough data that's kind of compressed into the weights, turns out to be an amazingly powerful operation to have at your disposal.&lt;/p&gt;
&lt;p&gt;[...] And the thing you can really see missing here is this planning piece, right? So if you try to get an LLM to solve fairly simple graph coloring problems or fairly simple stacking problems, things that require backtracking and trying things and stuff, unless it's something pretty similar in its training, they just fail terribly.&lt;/p&gt;
&lt;p&gt;[...] So that's the theory about what something like Q* might be, or just in general, how do we get past this current constraint that we have?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="https://www.youtube.com/live/6LXw2beprGI?si=I2JEqIccboFRou0K&amp;amp;t=1526"&gt;Jeremy Howard&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="jeremy-howard"/></entry><entry><title>A Hackers' Guide to Language Models</title><link href="https://simonwillison.net/2023/Sep/25/a-hackers-guide-to-language-models/#atom-tag" rel="alternate"/><published>2023-09-25T00:24:50+00:00</published><updated>2023-09-25T00:24:50+00:00</updated><id>https://simonwillison.net/2023/Sep/25/a-hackers-guide-to-language-models/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/watch?v=jkrNMKz9pWU"&gt;A Hackers&amp;#x27; Guide to Language Models&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Jeremy Howard’s new 1.5 hour YouTube introduction to language models looks like a really useful place to catch up if you’re an experienced Python programmer looking to start experimenting with LLMs. He covers what they are and how they work, then shows how to build against the OpenAI API, build a Code Interpreter clone using OpenAI functions, run models from Hugging Face on your own machine (with NVIDIA cards or on a Mac) and finishes with a demo of fine-tuning a Llama 2 model to perform text-to-SQL using an open dataset.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/openai"&gt;openai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llama"&gt;llama&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fine-tuning"&gt;fine-tuning&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nvidia"&gt;nvidia&lt;/a&gt;&lt;/p&gt;



</summary><category term="python"/><category term="ai"/><category term="openai"/><category term="generative-ai"/><category term="llama"/><category term="llms"/><category term="jeremy-howard"/><category term="fine-tuning"/><category term="nvidia"/></entry><entry><title>Mojo may be the biggest programming advance in decades</title><link href="https://simonwillison.net/2023/May/4/mojo/#atom-tag" rel="alternate"/><published>2023-05-04T04:41:03+00:00</published><updated>2023-05-04T04:41:03+00:00</updated><id>https://simonwillison.net/2023/May/4/mojo/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.fast.ai/posts/2023-05-03-mojo-launch.html"&gt;Mojo may be the biggest programming advance in decades&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Jeremy Howard makes a very convincing argument for why the new programming language Mojo is a big deal.&lt;/p&gt;

&lt;p&gt;Mojo is a superset of Python designed by a team lead by Chris Lattner, who previously created LLVM, Clang and and Swift.&lt;/p&gt;

&lt;p&gt;Existing Python code should work unmodified, but it also adds features that enable performant low-level programming—like “fn” for creating typed, compiled functions and “struct” for memory-optimized alternatives to classes.&lt;/p&gt;

&lt;p&gt;It’s worth watching Jeremy’s video where he uses these features to get more than a 2000x speed up implementing matrix multiplication, while still keeping the code readable and easy to follow.&lt;/p&gt;

&lt;p&gt;Mojo isn’t available yet outside of a playground preview environment, but it does look like an intriguing new project.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/hamelhusain/status/1653963183013634048"&gt;@hamelhusain&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/programming-languages"&gt;programming-languages&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mojo"&gt;mojo&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="programming-languages"/><category term="python"/><category term="ai"/><category term="mojo"/><category term="jeremy-howard"/></entry><entry><title>From Deep Learning Foundations to Stable Diffusion</title><link href="https://simonwillison.net/2023/Apr/5/from-deep-learning-foundations-to-stable-diffusion/#atom-tag" rel="alternate"/><published>2023-04-05T01:13:19+00:00</published><updated>2023-04-05T01:13:19+00:00</updated><id>https://simonwillison.net/2023/Apr/5/from-deep-learning-foundations-to-stable-diffusion/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.fast.ai/posts/part2-2023.html"&gt;From Deep Learning Foundations to Stable Diffusion&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Brand new free online video course from Jeremy Howard: 30 hours of content, covering everything you need to know to implement the Stable Diffusion image generation algorithm from scratch. I previewed parts of this course back in December and it was fascinating: this field is moving so fast that some of the lectures covered papers that had been released just a few days before.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fastai"&gt;fastai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/stable-diffusion"&gt;stable-diffusion&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/text-to-image"&gt;text-to-image&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="fastai"/><category term="stable-diffusion"/><category term="generative-ai"/><category term="jeremy-howard"/><category term="text-to-image"/></entry><entry><title>Your own hosted blog, the easy, free, open way (even if you're not a computer expert)</title><link href="https://simonwillison.net/2020/Jan/17/fast-template/#atom-tag" rel="alternate"/><published>2020-01-17T01:12:56+00:00</published><updated>2020-01-17T01:12:56+00:00</updated><id>https://simonwillison.net/2020/Jan/17/fast-template/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.fast.ai/2020/01/16/fast_template/"&gt;Your own hosted blog, the easy, free, open way (even if you&amp;#x27;re not a computer expert)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Jeremy Howard and the fast.ai team have released fast_template—a GitHub repository designed to be used as a template to create new repositories with a complete Jekyll blog configured for use with GitHub pages. GitHub’s official document recommends you install Ruby on your machine to do this, but Jeremy points out that with the right repository setup you can run a blog entirely by editing files through the GitHub web interface.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/jeremyphoward/status/1217909025259442176"&gt;@jeremyphoward&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/blogging"&gt;blogging&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/github"&gt;github&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;&lt;/p&gt;



</summary><category term="blogging"/><category term="github"/><category term="jeremy-howard"/></entry><entry><title>Automatically playing science communication games with transfer learning and fastai</title><link href="https://simonwillison.net/2018/Oct/29/transfer-learning/#atom-tag" rel="alternate"/><published>2018-10-29T03:16:33+00:00</published><updated>2018-10-29T03:16:33+00:00</updated><id>https://simonwillison.net/2018/Oct/29/transfer-learning/#atom-tag</id><summary type="html">
    &lt;p&gt;This weekend was the 9th annual &lt;a href="https://sf.sciencehackday.org/"&gt;Science Hack Day San Francisco&lt;/a&gt;, which was also the 100th Science Hack Day held worldwide.&lt;/p&gt;
&lt;p&gt;Natalie and I decided to combine our interests and build something fun.&lt;/p&gt;
&lt;p&gt;I’m currently enrolled in Jeremy Howard’s &lt;a href="http://course.fast.ai/"&gt;Deep Learning course&lt;/a&gt; so I figured this was a great opportunity to try out some computer vision.&lt;/p&gt;
&lt;p&gt;Natalie runs the &lt;a href="https://natbat.github.io/scicomm-calendar/"&gt;SciComm Games calendar&lt;/a&gt; and accompanying &lt;a href="https://twitter.com/SciCommGames"&gt;@SciCommGames&lt;/a&gt; bot to promote and catalogue science communication hashtag games on Twitter.&lt;/p&gt;
&lt;p&gt;Hashtag games? Natalie &lt;a href="https://natbat.github.io/scicomm-calendar/"&gt;explains them here&lt;/a&gt; - essentially they are games run by scientists on Twitter to foster public engagement around an animal or topic by challenging people to identify if a photo is a #cougarOrNot or participate in a #TrickyBirdID or identify #CrowOrNo or many others.&lt;/p&gt;
&lt;p&gt;Combining the two… we decided to build a bot that automatically plays these games using computer vision. So far it’s just trying #cougarOrNot - you can see the bot in action at &lt;a href="https://twitter.com/critter_vision/with_replies"&gt;@critter_vision&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Training_data_from_iNaturalist_14"&gt;&lt;/a&gt;Training data from iNaturalist&lt;/h3&gt;
&lt;p&gt;In order to build a machine learning model, you need to start out with some training data.&lt;/p&gt;
&lt;p&gt;I’m a big fan of &lt;a href="https://www.inaturalist.org/"&gt;iNaturalist&lt;/a&gt;, a citizen science project that encourages users to upload photographs of wildlife (and plants) they have seen and have their observations verified by a community. Natalie and I used it to build &lt;a href="https://www.owlsnearme.com/"&gt;owlsnearme.com&lt;/a&gt; earlier this year - the API in particular is fantastic.&lt;/p&gt;
&lt;p&gt;iNaturalist has &lt;a href="https://www.inaturalist.org/observations?place_id=1&amp;amp;taxon_id=41944"&gt;over 5,000 verified sightings&lt;/a&gt; of felines (cougars, bobcats, domestic cats and more) in the USA.&lt;/p&gt;
&lt;p&gt;The raw data is available as &lt;a href="http://api.inaturalist.org/v1/observations?identified=true&amp;amp;photos=true&amp;amp;identifications=most_agree&amp;amp;quality_grade=research&amp;amp;order=desc&amp;amp;order_by=created_at&amp;amp;taxon_id=41944&amp;amp;place_id=1&amp;amp;per_page=200"&gt;a paginated JSON API&lt;/a&gt;. The &lt;a href="https://static.inaturalist.org/photos/27333309/medium.jpg"&gt;medium sized photos&lt;/a&gt; are just the right size for training a neural network.&lt;/p&gt;
&lt;p&gt;I started by grabbing 5,000 images and saving them to disk with a filename that reflected their identified species:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Bobcat_9005106.jpg
Domestic-Cat_10068710.jpg
Bobcat_15713672.jpg
Domestic-Cat_6755280.jpg
Mountain-Lion_9075705.jpg
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a id="Building_a_model_32"&gt;&lt;/a&gt;Building a model&lt;/h3&gt;
&lt;p&gt;I’m only one week into the &lt;a href="http://www.fast.ai/"&gt;fast.ai&lt;/a&gt; course so this really isn’t particularly sophisticated yet, but it was just about good enough to power our hack.&lt;/p&gt;
&lt;p&gt;The main technique we are learning in the course is called &lt;a href="https://machinelearningmastery.com/transfer-learning-for-deep-learning/"&gt;transfer learning&lt;/a&gt;, and it really is shockingly effective. Instead of training a model from scratch you start out with a pre-trained model and use some extra labelled images to train a small number of extra layers.&lt;/p&gt;
&lt;p&gt;The initial model we are using is &lt;a href="https://www.kaggle.com/pytorch/resnet34"&gt;ResNet-34&lt;/a&gt;, a 34-layer neural network trained on 1,000 labelled categories in the &lt;a href="http://www.image-net.org/"&gt;ImageNet&lt;/a&gt; corpus.&lt;/p&gt;
&lt;p&gt;In class, we learned to use this technique to get 94% accuracy against the &lt;a href="http://www.robots.ox.ac.uk/~vgg/data/pets/"&gt;Oxford-IIIT Pet Dataset&lt;/a&gt; - around 7,000 images covering 12 cat breeds and 25 dog breeds. In 2012 the researchers at Oxford were able to get 59.21% using a sophisticated model - it 2018 we can get 94% with transfer learning and just a few lines of code.&lt;/p&gt;
&lt;p&gt;I started with an example provided in class, which loads and trains images from files on disk using a regular expression that extracts the labels from the filenames.&lt;/p&gt;
&lt;p&gt;My full Jupyter notebook is &lt;a href="https://github.com/simonw/cougar-or-not/blob/master/inaturalist-cats.ipynb"&gt;inaturalist-cats.ipynb&lt;/a&gt; - the key training code is as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from fastai import *
from fastai.vision import *
cat_images_path = Path('/home/jupyter/.fastai/data/inaturalist-usa-cats/images')
cat_fnames = get_image_files(cat_images_path)
cat_data = ImageDataBunch.from_name_re(
    cat_images_path,
    cat_fnames,
    r'/([^/]+)_\d+.jpg$',
    ds_tfms=get_transforms(),
    size=224
)
cat_data.normalize(imagenet_stats)
cat_learn = ConvLearner(cat_data, models.resnet34, metrics=error_rate)
cat_learn.fit_one_cycle(4)
# Save the generated model to disk
cat_learn.save(&amp;quot;usa-inaturalist-cats&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Calling &lt;code&gt;cat_learn.save(&amp;quot;usa-inaturalist-cats&amp;quot;)&lt;/code&gt; created an 84MB file on disk at &lt;code&gt;/home/jupyter/.fastai/data/inaturalist-usa-cats/images/models/usa-inaturalist-cats.pth&lt;/code&gt; - I used &lt;code&gt;scp&lt;/code&gt; to copy that model down to my laptop.&lt;/p&gt;
&lt;p&gt;This model gave me a 24% error rate which is pretty terrible - others on the course have been getting error rates less than 10% for all kinds of interesting problems. My focus was to get a model deployed as an API though so I haven’t spent any additional time fine-tuning things yet.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Deploying_the_model_as_an_API_67"&gt;&lt;/a&gt;Deploying the model as an API&lt;/h3&gt;
&lt;p&gt;The &lt;a href="https://github.com/fastai/fastai"&gt;fastai library&lt;/a&gt; strongly encourages training against a GPU, using &lt;a href="https://pytorch.org/"&gt;pytorch&lt;/a&gt; and &lt;a href="https://mathema.tician.de/software/pycuda/"&gt;PyCUDA&lt;/a&gt;. I’ve been using n1-highmem-8 Google Cloud Platform instance with an attached Tesla P4, then running everything in a Jupyter notebook there. This costs around $0.38 an hour - fine for a few hours of training, but way too expensive to permanently host a model.&lt;/p&gt;
&lt;p&gt;Thankfully, while a GPU is essential for productively training models it’s not nearly as important for evaluating them against new data. pytorch can run in CPU mode for that just fine on standard hardware, and the &lt;a href="https://github.com/fastai/fastai/blob/master/README.md"&gt;fastai README&lt;/a&gt; includes instructions on installing it for a CPU using pip.&lt;/p&gt;
&lt;p&gt;I started out by ensuring I could execute my generated model on my own laptop (since pytorch doesn’t yet work with the GPU built into the Macbook Pro). Once I had that working, I used the resulting code to write a tiny Starlette-powered API server. The code for that can be found in &lt;a href="https://github.com/simonw/cougar-or-not/blob/8adafac571aad3385317c76bd229448b3cdaa0ac/cougar.py"&gt;in cougar.py&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;fastai is under very heavy development and the latest version doesn’t quite have a clean way of loading a model from disk without also including the initial training images, so I had to hack around quite a bit to get this working using clues from &lt;a href="https://forums.fast.ai/"&gt;the fastai forums&lt;/a&gt;. I expect this to get much easier over the next few weeks as the library continues to evolve based on feedback from the current course.&lt;/p&gt;
&lt;p&gt;To deploy the API I wrote &lt;a href="https://github.com/simonw/cougar-or-not/blob/8adafac571aad3385317c76bd229448b3cdaa0ac/Dockerfile"&gt;a Dockerfile&lt;/a&gt; and shipped it to &lt;a href="https://zeit.co/now"&gt;Zeit Now&lt;/a&gt;. Now remains my go-to choice for this kind of project, though unfortunately their new (and brilliant) v2 platform imposes &lt;a href="https://github.com/zeit/now-cli/issues/1523"&gt;a 100MB image size limit&lt;/a&gt; - not nearly enough when the model file itself weights in at 83 MB. Thankfully it’s still possible to &lt;a href="https://github.com/simonw/cougar-or-not/commit/5ad3d5b49c6419e4c2440291bc5fb204625aae83"&gt;specify their v1 cloud&lt;/a&gt; which is more forgiving for larger applications.&lt;/p&gt;
&lt;p&gt;Here’s the result: an API which can accept either the URL to an image or an uploaded image file: &lt;a href="https://cougar-or-not.now.sh/"&gt;https://cougar-or-not.now.sh/&lt;/a&gt; - try it out with &lt;a href="https://cougar-or-not.now.sh/classify-url?url=https://upload.wikimedia.org/wikipedia/commons/9/9a/Oregon_Cougar_ODFW.JPG"&gt;a cougar&lt;/a&gt; and &lt;a href="https://cougar-or-not.now.sh/classify-url?url=https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Bobcat2.jpg/1200px-Bobcat2.jpg"&gt;a bobcat&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a id="The_Twitter_Bot_81"&gt;&lt;/a&gt;The Twitter Bot&lt;/h3&gt;
&lt;p&gt;Natalie built &lt;a href="https://github.com/natbat/CritterVision"&gt;the Twitter bot&lt;/a&gt;. It runs as a scheduled task on Heroku and works by checking for new #cougarOrNot tweets from &lt;a href="https://twitter.com/drmichellelarue"&gt;Dr. Michelle LaRue&lt;/a&gt;, extracting any images, passing them to my API and replying with a tweet that summarizes the results. Take a look at &lt;a href="https://twitter.com/critter_vision/with_replies"&gt;its recent replies&lt;/a&gt; to get a feel for how well it is doing.&lt;/p&gt;
&lt;p&gt;Amusingly, Dr. LaRue frequently tweets memes to promote upcoming competitions and marks them with the same hashtag. The bot appears to think that most of the memes are bobcats! I should definitely spend some time tuning that model.&lt;/p&gt;
&lt;p&gt;Science Hack Day was great fun. A big thanks to the organizing team, and congrats to all of the other participants. I’m really looking forward to the next one.&lt;/p&gt;
&lt;p&gt;Plus… we won a medal!&lt;/p&gt;
&lt;blockquote class="twitter-tweet" data-lang="en"&gt;&lt;p lang="en" dir="ltr"&gt;Enjoyed &lt;a href="https://twitter.com/hashtag/scienceHackday?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#scienceHackday&lt;/a&gt; this weekend, made &amp;amp; launched a cool machine learning hack to process images &amp;amp; work out if they have a cougar in them or not! &lt;a href="https://twitter.com/hashtag/CougarOrNot?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#CougarOrNot&lt;/a&gt; &lt;a href="https://twitter.com/critter_vision?ref_src=twsrc%5Etfw"&gt;@critter_vision&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;... we won a medal!&lt;br /&gt;&lt;br /&gt;Bot code: &lt;a href="https://t.co/W2jZcGCnFr"&gt;https://t.co/W2jZcGCnFr&lt;/a&gt;&lt;br /&gt;Machine learning API: &lt;a href="https://t.co/swNiKlcTp0"&gt;https://t.co/swNiKlcTp0&lt;/a&gt; &lt;a href="https://t.co/dcdIhNZy63"&gt;pic.twitter.com/dcdIhNZy63&lt;/a&gt;&lt;/p&gt;&amp;#8212; Natbat (@Natbat) &lt;a href="https://twitter.com/Natbat/status/1056717060116369410?ref_src=twsrc%5Etfw"&gt;October 29, 2018&lt;/a&gt;&lt;/blockquote&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/computer-vision"&gt;computer-vision&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/machine-learning"&gt;machine-learning&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/natalie-downe"&gt;natalie-downe&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/inaturalist"&gt;inaturalist&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fastai"&gt;fastai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/transferlearning"&gt;transferlearning&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jeremy-howard"&gt;jeremy-howard&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/starlette"&gt;starlette&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="computer-vision"/><category term="machine-learning"/><category term="natalie-downe"/><category term="inaturalist"/><category term="fastai"/><category term="transferlearning"/><category term="jeremy-howard"/><category term="starlette"/></entry></feed>