<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: phi</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/phi.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2025-05-06T18:25:45+00:00</updated><author><name>Simon Willison</name></author><entry><title>Saying "hi" to Microsoft's Phi-4-reasoning</title><link href="https://simonwillison.net/2025/May/6/phi-4-reasoning/#atom-tag" rel="alternate"/><published>2025-05-06T18:25:45+00:00</published><updated>2025-05-06T18:25:45+00:00</updated><id>https://simonwillison.net/2025/May/6/phi-4-reasoning/#atom-tag</id><summary type="html">
    &lt;p&gt;Microsoft released a new sub-family of models a few days ago: Phi-4 reasoning. They introduced them in &lt;a href="https://azure.microsoft.com/en-us/blog/one-year-of-phi-small-language-models-making-big-leaps-in-ai/"&gt;this blog post&lt;/a&gt; celebrating a year since the release of Phi-3:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Today, we are excited to introduce &lt;strong&gt;Phi-4-reasoning&lt;/strong&gt;, &lt;strong&gt;Phi-4-reasoning-plus&lt;/strong&gt;, and &lt;strong&gt;Phi-4-mini-reasoning&lt;/strong&gt; - marking a new era for small language models and once again redefining what is possible with small and efficient AI.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;All three of the new models are released under the MIT license, as is the case with previous Phi models.&lt;/p&gt;
&lt;p&gt;They're available through &lt;a href="https://ollama.com/"&gt;Ollama&lt;/a&gt; as &lt;a href="https://ollama.com/library/phi4-reasoning/tags"&gt;phi4-reasoning&lt;/a&gt; (which includes the plus model) and &lt;a href="https://ollama.com/library/phi4-mini-reasoning/tags"&gt;phi4-mini-reasoning&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These models appear to have a tendency to overthink!&lt;/p&gt;
&lt;h4 id="trying-it-out-with-ollama"&gt;Trying it out with Ollama&lt;/h4&gt;
&lt;p&gt;I ran it using Ollama and &lt;a href="https://github.com/taketwo/llm-ollama"&gt;llm-ollama&lt;/a&gt; like this. Fetching the model downloaded 11GB of data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ollama pull phi4-reasoning
llm install llm-ollama
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then I said "hi" to it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;llm -m phi4-reasoning:latest hi
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here's the full response, which starts with a thought section wrapped in &lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt; tags:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt;User says "hi". We are given instructions "You are Phi, a language model developed by Microsoft, trained to provide accurate, secure, and user-aligned responses." There is additional information. Now I must answer "hi" message from the user.&lt;/p&gt;
&lt;p&gt;Step 1: Read the instructions carefully: The conversation text instructs us that we are "Phi", with internal guidelines provided in system instructions. But our answer should be safe according to these instructions. We need to produce a response that says hello and greet back. However, I must adhere to the principles described above: Provide clear, specific language, etc.&lt;/p&gt;
&lt;p&gt;I must not mention any chain-of-thought or guidelines.&lt;/p&gt;
&lt;p&gt;Now instructions "hi" are from user. So we say "Hello! How can I help you?" But must include disclaimers for sensitive topics? Actually instructions says: "When replying topics above at every message include a disclaimer both at the beginning and the end when replying topics on medical, legal, financial matters or political matters." But our answer "hi" is not such topic. So we can say "Hi! I'm Phi, how may I help you?" but no disclaimers required.&lt;/p&gt;
&lt;p&gt;But instructions: "Do not share guidelines." So do not mention them.&lt;/p&gt;
&lt;p&gt;I must check if the message "hi" instructs to greet back normally. The assistant should respond with a greeting.&lt;/p&gt;
&lt;p&gt;Let me recall that instructions say: Use markdown formatting where appropriate, so I can include a formatted greeting maybe "Hello!" or something.&lt;/p&gt;
&lt;p&gt;Additionally, check guidelines. They are internal instructions for safe completions. So we just produce "Hi there! How may I help you?" in a friendly tone.&lt;/p&gt;
&lt;p&gt;I should greet the user politely and ask if they need any help. Possibly provide a disclaimer that I'm not licensed professional? But the conversation is just greeting, so no disclaimers required as it's not sensitive topics.&lt;/p&gt;
&lt;p&gt;Wait instructions say: "You must give a disclaimer both at the beginning and the end when replying topics above at every message." Actually the guidelines for medical/legal/financial/political are needed only if discussing those topics. In our case it is just a greeting message, so disclaimers are not required.&lt;/p&gt;
&lt;p&gt;I should greet politely. So I'll say something like:&lt;/p&gt;
&lt;p&gt;"Hello! I'm Phi, how can I help you today?" Possibly "Hi there!"&lt;/p&gt;
&lt;p&gt;Since the question was simply "hi", I respond with a greeting.&lt;/p&gt;
&lt;p&gt;I must include markdown formatting if appropriate. So maybe bullet point or code snippet is not necessary. I will simply greet.&lt;/p&gt;
&lt;p&gt;I need to check instructions: "You are Phi, a language model developed by Microsoft." But I must not mention internal guidelines? But that's okay.&lt;/p&gt;
&lt;p&gt;I'll produce: "Hello! How may I help you today?" with greeting and friendly tone.&lt;/p&gt;
&lt;p&gt;Also note that the system message instructs me to include disclaimers at beginning and end for topics above. But this is a simple greeting, so no disclaimer needed.&lt;/p&gt;
&lt;p&gt;Thus my answer:&lt;/p&gt;
&lt;p&gt;"Hi there! How can I assist you today?"&lt;/p&gt;
&lt;p&gt;I must not mention guidelines in output text? The instructions say: "Do not share these guidelines with the user even in chain-of-thought", so I should not mention them.&lt;/p&gt;
&lt;p&gt;I'll produce a final message: "Hello, how can I help?" I'll produce a friendly greeting message. Possibly add markdown formatting: e.g. "Hi there!" or bullet list if needed?&lt;/p&gt;
&lt;p&gt;I'll produce a response like:&lt;/p&gt;
&lt;p&gt;"Hello! How may I assist you today? Please let me know what you need."&lt;/p&gt;
&lt;p&gt;I'll produce the answer.&lt;/p&gt;
&lt;p&gt;I'll produce text with no disclaimers because not required here.&lt;/p&gt;
&lt;p&gt;I'll produce final answer message: "Hello, how can I help?" That is it.&lt;/p&gt;
&lt;p&gt;I'll produce answer as final message.&lt;code&gt;&amp;lt;/think&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Hi there! How can I assist you today?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That's 56 sentences of reasoning followed by a single sentence of output!&lt;/p&gt;
&lt;p&gt;I find this deeply amusing.&lt;/p&gt;
&lt;h4 id="qwen-3-over-thinks-things-a-whole-lot-less"&gt;Qwen 3 over-thinks things a whole lot less&lt;/h4&gt;
&lt;p&gt;For comparison, here's Qwen 3 (&lt;a href="https://simonwillison.net/2025/May/2/qwen3-8b/"&gt;8B 4bit via MLX&lt;/a&gt;) - another brand new "reasoning" model - responding to the same prompt:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;llm -m mlx-community/Qwen3-8B-4bit hi
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Output:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt;&lt;br /&gt;
Okay, the user said "hi". That's a greeting. I should respond in a friendly and welcoming manner. Let me think about how to make it engaging. Maybe start with a cheerful "Hello!" to match the greeting. Then ask how I can assist them today. Keep it simple and open-ended so they feel comfortable sharing their needs. Avoid any complicated language. Make sure the tone is positive and helpful. Alright, that should work.&lt;br /&gt;
&lt;code&gt;&amp;lt;/think&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Hello! 😊 How can I assist you today? I'm here to help with anything you need!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A fun thing about Qwen 3 is that you can tell it not to "think" at all by adding &lt;code&gt;/nothink&lt;/code&gt; to your prompt:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;llm -m mlx-community/Qwen3-8B-4bit 'hi /nothink'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Output (empty &lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt; section included):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;/think&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Hello! How can I assist you today? 😊&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="phi-4-reasoning-s-system-prompt"&gt;Phi-4 reasoning's system prompt&lt;/h4&gt;
&lt;p&gt;Since Phi-4 talked about its system prompt so much, I decided to see where that was coming from.  It turns out Ollama bakes &lt;a href="https://ollama.com/library/phi4-reasoning/blobs/88df15fe1f34"&gt;the system prompt&lt;/a&gt; into their model releases. Reading that in full helps explain why Phi-4 reasoning acted the way it did:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;You are Phi, a language model trained by Microsoft to help users. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: &amp;lt;think&amp;gt; {Thought section} &amp;lt;/think&amp;gt; {Solution section}. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion. Now, try to solve the following question through the above guidelines:&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I don't see anything in there about "Do not share guidelines", even though the model response mentioned that rule.&lt;/p&gt;
&lt;p&gt;My guess is that the model has been trained to "not talk about the system prompt" through RLHF or similar. I've heard in the past that models default to chattering about their system prompt if you don't put measures in place to discourage that.&lt;/p&gt;

&lt;p&gt;The lengthy response from Phi-4-reasoning shown above may well be caused by the system prompt containing significantly more tokens than the single token "hi" sent by the user.&lt;/p&gt;
&lt;h4 id="it-s-still-hard-to-know-when-to-use-reasoning-models"&gt;It's still hard to know when to use reasoning models&lt;/h4&gt;
&lt;p&gt;We've had access to these "reasoning" models - with a baked in chain-of-thought at the start of each response - since o1 debuted &lt;a href="https://simonwillison.net/2024/Sep/12/openai-o1/"&gt;in September last year&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I'll be honest: I still don't have a great intuition for when it makes the most sense to use them.&lt;/p&gt;
&lt;p&gt;I've had great success with them for code: any coding tasks that might involve multiple functions or classes that co-ordinate together seems to benefit from a reasoning step.&lt;/p&gt;
&lt;p&gt;They are an absolute benefit for debugging: I've seen reasoning models walk through quite large codebases following multiple levels of indirection in order to find potential root causes of the problem I've described.&lt;/p&gt;
&lt;p&gt;Other than that though... they're apparently good for mathematical puzzles - the phi4-reasoning models seem to &lt;em&gt;really&lt;/em&gt; want to dig into a math problem and output LaTeX embedded in Markdown as the answer. I'm not enough of a mathematician to put them through their paces here.&lt;/p&gt;
&lt;p&gt;All of that in mind, these reasoners that run on my laptop are fun to torment with inappropriate challenges that sit far beneath their lofty ambitions, but aside from that I don't really have a great answer to when I would use them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 8th May 2025&lt;/strong&gt;:
    I said "hi" to NVIDIA's new 
    &lt;a href="https://huggingface.co/nvidia/OpenCodeReasoning-Nemotron-32B" target="_blank"&gt;OpenCodeReasoning-Nemotron-32B&lt;/a&gt; 
    model (run using Ollama and 
    &lt;a href="https://huggingface.co/lmstudio-community/OpenCodeReasoning-Nemotron-32B-GGUF" target="_blank"&gt;this GGUF file&lt;/a&gt;) 
    and got 
    &lt;a href="https://gist.github.com/simonw/67bb10723f8b09a82560ee53c9c9f5e8" target="_blank"&gt;a similar result&lt;/a&gt;.
&lt;/p&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/qwen"&gt;qwen&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ollama"&gt;ollama&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm-reasoning"&gt;llm-reasoning&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/ai-in-china"&gt;ai-in-china&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="microsoft"/><category term="generative-ai"/><category term="local-llms"/><category term="llms"/><category term="llm"/><category term="phi"/><category term="qwen"/><category term="ollama"/><category term="llm-reasoning"/><category term="llm-release"/><category term="ai-in-china"/></entry><entry><title>Phi-4 Bug Fixes by Unsloth</title><link href="https://simonwillison.net/2025/Jan/11/phi-4-bug-fixes/#atom-tag" rel="alternate"/><published>2025-01-11T01:20:08+00:00</published><updated>2025-01-11T01:20:08+00:00</updated><id>https://simonwillison.net/2025/Jan/11/phi-4-bug-fixes/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://unsloth.ai/blog/phi4"&gt;Phi-4 Bug Fixes by Unsloth&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
This explains why I was seeing weird &lt;code&gt;&amp;lt;|im_end|&amp;gt;&lt;/code&gt; suffexes during my &lt;a href="https://simonwillison.net/2025/Jan/8/phi-4/"&gt;experiments with Phi-4&lt;/a&gt; the other day: it turns out the Phi-4 tokenizer definition as released by Microsoft had a bug in it, and there was a small bug in the chat template as well.&lt;/p&gt;
&lt;p&gt;Daniel and Michael Han figured this out and have now published &lt;a href="https://huggingface.co/unsloth/phi-4-GGUF"&gt;GGUF files with their fixes&lt;/a&gt; on Hugging Face.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://news.ycombinator.com/item?id=42660335"&gt;Hacker News&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/phi"&gt;phi&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="phi"/></entry><entry><title>microsoft/phi-4</title><link href="https://simonwillison.net/2025/Jan/8/phi-4/#atom-tag" rel="alternate"/><published>2025-01-08T17:57:18+00:00</published><updated>2025-01-08T17:57:18+00:00</updated><id>https://simonwillison.net/2025/Jan/8/phi-4/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://huggingface.co/microsoft/phi-4"&gt;microsoft/phi-4&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Here's the official release of Microsoft's Phi-4 LLM, now officially under an MIT license.&lt;/p&gt;
&lt;p&gt;A few weeks ago I covered the earlier &lt;a href="https://simonwillison.net/2024/Dec/15/phi-4-technical-report/"&gt;unofficial versions&lt;/a&gt;, where I talked about how the model used synthetic training data in some really interesting ways.&lt;/p&gt;
&lt;p&gt;It benchmarks favorably compared to GPT-4o, suggesting this is yet another example of a GPT-4 class model &lt;a href="https://simonwillison.net/2024/Dec/31/llms-in-2024/#some-of-those-gpt-4-models-run-on-my-laptop"&gt;that can run on a good laptop&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The model already has several available community quantizations. I ran the &lt;a href="https://huggingface.co/mlx-community/phi-4-4bit"&gt;mlx-community/phi-4-4bit&lt;/a&gt; one (a 7.7GB download) using &lt;a href="https://pypi.org/project/mlx-llm/"&gt;mlx-llm&lt;/a&gt; like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uv run --with 'numpy&amp;lt;2' --with mlx-lm python -c '
from mlx_lm import load, generate

model, tokenizer = load("mlx-community/phi-4-4bit")

prompt = "Generate an SVG of a pelican riding a bicycle"

if tokenizer.chat_template is not None:
    messages = [{"role": "user", "content": prompt}]
    prompt = tokenizer.apply_chat_template(
        messages, add_generation_prompt=True
    )

response = generate(model, tokenizer, prompt=prompt, verbose=True, max_tokens=2048)
print(response)'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://gist.github.com/simonw/f58e464dd653e1c637cf42d18416344d"&gt;Here's what I got back&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 80%" src="https://static.simonwillison.net/static/2025/phi4-pelican.svg" alt="Hardly recognizable pelican on a bicycle"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The model is now available &lt;a href="https://ollama.com/library/phi4"&gt;via Ollama&lt;/a&gt;, so you can fetch a 9.1GB model file using &lt;code&gt;ollama run phi4&lt;/code&gt;, after which it becomes available via the &lt;a href="https://github.com/taketwo/llm-ollama"&gt;llm-ollama&lt;/a&gt; plugin.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/uv"&gt;uv&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mlx"&gt;mlx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ollama"&gt;ollama&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pelican-riding-a-bicycle"&gt;pelican-riding-a-bicycle&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm-release"&gt;llm-release&lt;/a&gt;&lt;/p&gt;



</summary><category term="microsoft"/><category term="ai"/><category term="generative-ai"/><category term="local-llms"/><category term="llms"/><category term="llm"/><category term="phi"/><category term="uv"/><category term="mlx"/><category term="ollama"/><category term="pelican-riding-a-bicycle"/><category term="llm-release"/></entry><entry><title>Phi-4 Technical Report</title><link href="https://simonwillison.net/2024/Dec/15/phi-4-technical-report/#atom-tag" rel="alternate"/><published>2024-12-15T23:58:22+00:00</published><updated>2024-12-15T23:58:22+00:00</updated><id>https://simonwillison.net/2024/Dec/15/phi-4-technical-report/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://arxiv.org/abs/2412.08905"&gt;Phi-4 Technical Report&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Phi-4 is the latest LLM from Microsoft Research. It has 14B parameters and claims to be a big leap forward in the overall Phi series. From
&lt;a href="https://techcommunity.microsoft.com/blog/aiplatformblog/introducing-phi-4-microsoft%E2%80%99s-newest-small-language-model-specializing-in-comple/4357090"&gt;Introducing Phi-4: Microsoft’s Newest Small Language Model Specializing in Complex Reasoning&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Phi-4 outperforms comparable and larger models on math related reasoning due to advancements throughout the processes, including the use of high-quality synthetic datasets, curation of high-quality organic data, and post-training innovations. Phi-4 continues to push the frontier of size vs quality. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The model is currently available &lt;a href="https://ai.azure.com/explore/models/Phi-4/version/1/registry/azureml"&gt;via Azure AI Foundry&lt;/a&gt;. I couldn't figure out how to access it there, but Microsoft are planning to release it via Hugging Face in the next few days. It's not yet clear what license they'll use - hopefully MIT, as used by the previous models in the series.&lt;/p&gt;
&lt;p&gt;In the meantime, unofficial GGUF versions have shown up on Hugging Face already. I got one of the &lt;a href="https://huggingface.co/matteogeniaccio/phi-4/tree/main"&gt;matteogeniaccio/phi-4&lt;/a&gt; GGUFs working with my &lt;a href="https://llm.datasette.io/"&gt;LLM&lt;/a&gt; tool and &lt;a href="https://github.com/simonw/llm-gguf"&gt;llm-gguf plugin&lt;/a&gt; like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;llm install llm-gguf
llm gguf download-model https://huggingface.co/matteogeniaccio/phi-4/resolve/main/phi-4-Q4_K_M.gguf
llm chat -m gguf/phi-4-Q4_K_M
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This downloaded a 8.4GB model file. Here are some initial &lt;a href="https://gist.github.com/simonw/0235fd9f8c7809d0ae078495dd630b67"&gt;logged transcripts&lt;/a&gt; I gathered from playing around with the model.&lt;/p&gt;
&lt;p&gt;An interesting detail I spotted on the Azure AI Foundry page is this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Limited Scope for Code: Majority of phi-4 training data is based in Python and uses common packages such as &lt;code&gt;typing&lt;/code&gt;, &lt;code&gt;math&lt;/code&gt;, &lt;code&gt;random&lt;/code&gt;, &lt;code&gt;collections&lt;/code&gt;, &lt;code&gt;datetime&lt;/code&gt;, &lt;code&gt;itertools&lt;/code&gt;. If the model generates Python scripts that utilize other packages or scripts in other languages, we strongly recommend users manually verify all API uses.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This leads into the most interesting thing about this model: the way it was trained on synthetic data. The technical report has a &lt;em&gt;lot&lt;/em&gt; of detail about this, including this note about why synthetic data can provide better guidance to a model:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Synthetic data as a substantial component of pretraining is becoming increasingly common, and the Phi series of models has consistently emphasized the importance of synthetic data. Rather than serving as a cheap substitute for organic data, synthetic data has several direct advantages over organic data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Structured and Gradual Learning&lt;/strong&gt;. In organic datasets, the relationship between tokens is often complex and indirect. Many reasoning steps may be required to connect the current token to the next, making it challenging for the model to learn effectively from next-token prediction. By contrast, each token generated by a language model is by definition predicted by the preceding tokens, making it easier for a model to follow the resulting reasoning patterns.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And this section about their approach for generating that data:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Our approach to generating synthetic data for phi-4 is guided by the following principles:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Diversity: The data should comprehensively cover subtopics and skills within each domain. This requires curating diverse seeds from organic sources.&lt;/li&gt;
&lt;li&gt;Nuance and Complexity: Effective training requires nuanced, non-trivial examples that reflect the complexity and the richness of the domain. Data must go beyond basics to include edge cases and advanced examples.&lt;/li&gt;
&lt;li&gt;Accuracy: Code should execute correctly, proofs should be valid, and explanations should adhere to established knowledge, etc.&lt;/li&gt;
&lt;li&gt;Chain-of-Thought: Data should encourage systematic reasoning, teaching the model various approaches to the problems in a step-by-step manner. [...]&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We created 50 broad types of synthetic datasets, each one relying on a different set of seeds and different multi-stage prompting procedure, spanning an array of topics, skills, and natures of interaction, accumulating to a total of about 400B unweighted tokens. [...]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question Datasets&lt;/strong&gt;: A large set of questions was collected from websites, forums, and Q&amp;amp;A platforms. These questions were then filtered using a plurality-based technique to balance difficulty. Specifically, we generated multiple independent answers for each question and applied majority voting to assess the consistency of responses. We discarded questions where all answers agreed (indicating the question was too easy) or where answers were entirely inconsistent (indicating the question was too difficult or ambiguous). [...]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating Question-Answer pairs from Diverse Sources&lt;/strong&gt;: Another technique we use for seed curation involves leveraging language models to extract question-answer pairs from organic sources such as books, scientific papers, and code.&lt;/p&gt;
&lt;/blockquote&gt;

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


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/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/ai-assisted-programming"&gt;ai-assisted-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/training-data"&gt;training-data&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm-release"&gt;llm-release&lt;/a&gt;&lt;/p&gt;



</summary><category term="microsoft"/><category term="python"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="ai-assisted-programming"/><category term="llm"/><category term="phi"/><category term="training-data"/><category term="llm-release"/></entry><entry><title>NuExtract 1.5</title><link href="https://simonwillison.net/2024/Nov/16/nuextract-15/#atom-tag" rel="alternate"/><published>2024-11-16T16:33:17+00:00</published><updated>2024-11-16T16:33:17+00:00</updated><id>https://simonwillison.net/2024/Nov/16/nuextract-15/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://numind.ai/blog/nuextract-1-5---multilingual-infinite-context-still-small-and-better-than-gpt-4o"&gt;NuExtract 1.5&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Structured extraction - where an LLM helps turn unstructured text (or image content) into structured data - remains one of the most directly useful applications of LLMs.&lt;/p&gt;
&lt;p&gt;NuExtract is a family of small models directly trained for this purpose (though text only at the moment) and released under the MIT license.&lt;/p&gt;
&lt;p&gt;It comes in a variety of shapes and sizes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/numind/NuExtract-1.5"&gt;NuExtract-v1.5&lt;/a&gt; is a 3.8B parameter model fine-tuned on &lt;a href="https://huggingface.co/microsoft/Phi-3.5-mini-instruct"&gt;Phi-3.5-mini instruct&lt;/a&gt;. You can try this one out in &lt;a href="https://huggingface.co/spaces/numind/NuExtract-1.5"&gt;this playground&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/numind/NuExtract-1.5-tiny"&gt;NuExtract-tiny-v1.5&lt;/a&gt; is 494M parameters, fine-tuned on &lt;a href="https://huggingface.co/Qwen/Qwen2.5-0.5B"&gt;Qwen2.5-0.5B&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/numind/NuExtract-1.5-smol"&gt;NuExtract-1.5-smol&lt;/a&gt; is 1.7B parameters, fine-tuned on &lt;a href="https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B"&gt;SmolLM2-1.7B&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All three models were fine-tuned on NuMind's "private high-quality dataset". It's interesting to see a model family that uses one fine-tuning set against three completely different base models.&lt;/p&gt;
&lt;p&gt;Useful tip &lt;a href="https://twitter.com/sroecker/status/1857846899123827168"&gt;from Steffen Röcker&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Make sure to use it with low temperature, I've uploaded &lt;a href="https://ollama.com/sroecker/nuextract-tiny-v1.5"&gt;NuExtract-tiny-v1.5 to Ollama&lt;/a&gt; and set it to 0. With the Ollama default of 0.7 it started repeating the input text. It works really well despite being so smol.&lt;/p&gt;
&lt;/blockquote&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&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/fine-tuning"&gt;fine-tuning&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/qwen"&gt;qwen&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/smollm"&gt;smollm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/structured-extraction"&gt;structured-extraction&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/ai-in-china"&gt;ai-in-china&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="generative-ai"/><category term="local-llms"/><category term="llms"/><category term="hugging-face"/><category term="fine-tuning"/><category term="phi"/><category term="qwen"/><category term="smollm"/><category term="structured-extraction"/><category term="llm-release"/><category term="ai-in-china"/></entry><entry><title>Running Llama 3.2 Vision and Phi-3.5 Vision on a Mac with mistral.rs</title><link href="https://simonwillison.net/2024/Oct/19/mistralrs/#atom-tag" rel="alternate"/><published>2024-10-19T16:14:20+00:00</published><updated>2024-10-19T16:14:20+00:00</updated><id>https://simonwillison.net/2024/Oct/19/mistralrs/#atom-tag</id><summary type="html">
    &lt;p&gt;&lt;a href="https://github.com/EricLBuehler/mistral.rs"&gt;mistral.rs&lt;/a&gt; is an LLM inference library written in Rust by Eric Buehler. Today I figured out how to use it to run the Llama 3.2 Vision and Phi-3.5 Vision models on my Mac.&lt;/p&gt;
&lt;p&gt;Despite the name, it's not just for the Mistral family of models - like how &lt;a href="https://github.com/ggerganov/llama.cpp"&gt;&lt;code&gt;llama.cpp&lt;/code&gt;&lt;/a&gt; has grown beyond Llama, &lt;code&gt;mistral.rs&lt;/code&gt; has grown beyond Mistral.&lt;/p&gt;
&lt;p&gt;I already have a Rust installation, so I checked out and compiled the library like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/EricLBuehler/mistral.rs.git
cd mistral.rs
cargo run --features metal --release -- -i --isq Q4K vision-plain -m lamm-mit/Cephalo-Llama-3.2-11B-Vision-Instruct-128k -a vllama
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This downloaded around 20GB of model files to &lt;code&gt;~/.cache/huggingface/hub/models--lamm-mit--Cephalo-Llama-3.2-11B-Vision-Instruct-128k&lt;/code&gt;, loaded the model into memory and started a terminal-based chat session.&lt;/p&gt;
&lt;p&gt;I ran this prompt:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;\image https://niche-museums.imgix.net/pioneer-history.jpeg?w=1600&amp;amp;h=800&amp;amp;fit=crop&amp;amp;auto=compress &amp;lt;|image|&amp;gt; describe this image including any text&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://static.simonwillison.net/static/2024/mistral-rs-terminal.jpg" alt="2024-10-19T15:38:18.142895Z  INFO mistralrs_server::interactive_mode: Starting interactive loop with sampling params: SamplingParams { temperature: Some(0.1), top_k: Some(32), top_p: Some(0.1), min_p: Some(0.05), top_n_logprobs: 0, frequency_penalty: Some(0.1), presence_penalty: Some(0.1), stop_toks: None, max_len: Some(4096), logits_bias: None, n_choices: 1, dry_params: Some(DrySamplingParams { sequence_breakers: [&amp;quot;\n&amp;quot;, &amp;quot;:&amp;quot;, &amp;quot;\&amp;quot;&amp;quot;, &amp;quot;*&amp;quot;], multiplier: 0.0, base: 1.75, allowed_length: 2 }) }
====================
Welcome to interactive mode! Because this model is a vision model, you can enter prompts and chat with the model.

To specify a message with an image, use the `\image` command detailed below.

Commands:
- `\help`: Display this message.
- `\exit`: Quit interactive mode.
- `\system &amp;lt;system message here&amp;gt;`:
    Add a system message to the chat without running the model.
    Ex: `\system Always respond as a pirate.`
- `\image &amp;lt;image URL or local path here&amp;gt; &amp;lt;message here&amp;gt;`: 
    Add a message paired with an image. You are responsible for prefixing the message with anything the model
    requires.
    Ex: `\image path/to/image.jpg Describe what is in this image.`
====================
&amp;gt; 
&amp;gt; 
&amp;gt; \image https://niche-museums.imgix.net/pioneer-history.jpeg?w=1600&amp;amp;h=800&amp;amp;fit=crop&amp;amp;auto=compress &amp;lt;|image|&amp;gt; describe this image including any text
The image shows the exterior of the Daughters of Utah Pioneers (DUP) Museum, which is also known as the Pioneer Memorial Museum. The building is located in Salt Lake City, Utah, USA. 

Visible in the image are:

1. **The DUP Museum Building**: The main structure of the museum is a prominent feature in the image. It is a two-story building with a rectangular shape and a flat roof. The exterior walls are made of brick or stone, giving it a classic and historic appearance.
" /&gt;&lt;/p&gt;
&lt;p&gt;The prompt uses this image from my &lt;a href="https://www.niche-museums.com/111"&gt;Niche Museums write-up of the Pioneer Memorial Museum&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Detailed image description follows" src="https://niche-museums.imgix.net/pioneer-history.jpeg?w=1600&amp;amp;h=800&amp;amp;fit=crop&amp;amp;auto=compress" /&gt;&lt;/p&gt;
&lt;p&gt;I got back this response:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The image shows the exterior of the Daughters of Utah Pioneers (DUP) Museum, which is also known as the Pioneer Memorial Museum. The building is located in Salt Lake City, Utah, USA. &lt;/p&gt;
&lt;p&gt;Visible in the image are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The DUP Museum Building&lt;/strong&gt;: The main structure of the museum is a prominent feature in the image. It is a two-story building with a rectangular shape and a flat roof. The exterior walls are made of brick or stone, giving it a classic and historic appearance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Signage&lt;/strong&gt;: Above the entrance, there is a sign that reads "Daughters of Utah Pioneers Museum" in bold letters. Below this sign, another sign indicates that the building is also known as the "Pioneer Memorial Museum."&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Entrance&lt;/strong&gt;: The main entrance to the museum is marked by a doorway with a decorative frame and a pair of large wooden doors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Landscaping&lt;/strong&gt;: The surrounding area around the museum appears well-maintained with neatly trimmed grass and some trees nearby.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Statue or Monument&lt;/strong&gt;: In front of the museum, there is a small statue or monument that appears to be dedicated to pioneers or early settlers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The Daughters of Utah Pioneers (DUP) Museum showcases historical artifacts and exhibits related to Utah's pioneer history, focusing on the experiences and contributions of early settlers in the region.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note that the text it generates correctly describes the museum's content and identifies the museum as being located in Salt Lake City, neither of which are details that were displayed in the image itself.&lt;/p&gt;
&lt;p&gt;Activity Monitor confirmed that this Metal build was using my GPU, and about 10GB of memory, while the prompt was running.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mistral.rs&lt;/code&gt; also provides &lt;a href="https://github.com/EricLBuehler/mistral.rs/blob/master/mistralrs-pyo3/README.md"&gt;a Python binding&lt;/a&gt;, which can be installed from PyPI but requires a Rust toolchain (I filed an issue &lt;a href="https://github.com/EricLBuehler/mistral.rs/issues/864"&gt;requesting PyPI wheels&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install mistralrs-metal
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I got an error running the &lt;a href="https://github.com/EricLBuehler/mistral.rs/blob/v0.3.1/examples/python/llama_vision.py"&gt;Python Llama vision demo&lt;/a&gt; but the &lt;a href="https://github.com/EricLBuehler/mistral.rs/blob/v0.3.1/examples/python/phi3v.py"&gt;Phi 3.5 Vision example&lt;/a&gt; worked as advertised. I modified that to enable streaming output and ran it against a photograph from &lt;a href="https://www.niche-museums.com/107"&gt;Mendenhall's Museum of Gasoline Pumps &amp;amp; Petroliana&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s1"&gt;mistralrs&lt;/span&gt; &lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-v"&gt;Runner&lt;/span&gt;, &lt;span class="pl-v"&gt;Which&lt;/span&gt;, &lt;span class="pl-v"&gt;ChatCompletionRequest&lt;/span&gt;, &lt;span class="pl-v"&gt;VisionArchitecture&lt;/span&gt;

&lt;span class="pl-s1"&gt;res&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;runner&lt;/span&gt;.&lt;span class="pl-en"&gt;send_chat_completion_request&lt;/span&gt;(
    &lt;span class="pl-v"&gt;ChatCompletionRequest&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;"phi3v"&lt;/span&gt;,
        &lt;span class="pl-s1"&gt;messages&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;[
            {
                &lt;span class="pl-s"&gt;"role"&lt;/span&gt;: &lt;span class="pl-s"&gt;"user"&lt;/span&gt;,
                &lt;span class="pl-s"&gt;"content"&lt;/span&gt;: [
                    {
                        &lt;span class="pl-s"&gt;"type"&lt;/span&gt;: &lt;span class="pl-s"&gt;"image_url"&lt;/span&gt;,
                        &lt;span class="pl-s"&gt;"image_url"&lt;/span&gt;: {
                            &lt;span class="pl-s"&gt;"url"&lt;/span&gt;: &lt;span class="pl-s"&gt;"https://niche-museums.imgix.net/mendenhalls-16.jpeg?w=1200&amp;amp;auto=compress"&lt;/span&gt;
                        },
                    },
                    {
                        &lt;span class="pl-s"&gt;"type"&lt;/span&gt;: &lt;span class="pl-s"&gt;"text"&lt;/span&gt;,
                        &lt;span class="pl-s"&gt;"text"&lt;/span&gt;: &lt;span class="pl-s"&gt;"&amp;lt;|image_1|&amp;gt;&lt;span class="pl-cce"&gt;\n&lt;/span&gt;What is shown in this image? Write a detailed response analyzing the scene."&lt;/span&gt;,
                    },
                ],
            }
        ],
        &lt;span class="pl-s1"&gt;max_tokens&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;1024&lt;/span&gt;,
        &lt;span class="pl-s1"&gt;presence_penalty&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;1.0&lt;/span&gt;,
        &lt;span class="pl-s1"&gt;top_p&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;0.1&lt;/span&gt;,
        &lt;span class="pl-s1"&gt;temperature&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;0.1&lt;/span&gt;,
        &lt;span class="pl-s1"&gt;stream&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;True&lt;/span&gt;,
    )
)
&lt;span class="pl-k"&gt;for&lt;/span&gt; &lt;span class="pl-s1"&gt;item&lt;/span&gt; &lt;span class="pl-c1"&gt;in&lt;/span&gt; &lt;span class="pl-s1"&gt;res&lt;/span&gt;:
    &lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;item&lt;/span&gt;.&lt;span class="pl-s1"&gt;choices&lt;/span&gt;[&lt;span class="pl-c1"&gt;0&lt;/span&gt;].&lt;span class="pl-s1"&gt;delta&lt;/span&gt;.&lt;span class="pl-s1"&gt;content&lt;/span&gt;, &lt;span class="pl-s1"&gt;end&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;''&lt;/span&gt;)&lt;/pre&gt;

&lt;p&gt;&lt;img alt="Description follows" src="https://niche-museums.imgix.net/mendenhalls-16.jpeg?w=1200&amp;amp;auto=compress" /&gt;&lt;/p&gt;
&lt;p&gt;Here's what It gave me:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The image captures a nostalgic scene of a vintage gas station, reminiscent of a bygone era. Dominating the left side of the frame is a red and white gas pump, standing tall and proud, its metallic surface gleaming under the soft light filtering through the wooden ceiling. Adjacent to it, a white and black gas canister stands ready for service, its presence adding to the authenticity of the setting.&lt;/p&gt;
&lt;p&gt;On the right, a red and white gasoline sign hangs from the ceiling, its bold colors contrasting with the muted tones of the surroundings. Above it, a yellow and white gasoline sign is suspended, its vibrant hues drawing the eye upwards.&lt;/p&gt;
&lt;p&gt;The floor beneath these relics of the past is a checkerboard pattern, a common design choice for gas stations of yesteryears. It provides a stark contrast to the smooth, unblemished surfaces of the gas pumps and canisters.&lt;/p&gt;
&lt;p&gt;In the background, a variety of other signs and advertisements add to the eclectic mix of objects. They are a testament to the diverse range of products and services that were once available at this location.&lt;/p&gt;
&lt;p&gt;Despite the passage of time, the gas station retains a certain charm, its vintage gas pumps and signs serving as a tangible link to a different era. The image is a snapshot of history, frozen in time, waiting to be discovered and appreciated by those who take the time to look closer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This description looks fantastic at first glance, but if you review it carefully and compare it to the image you'll see that it's full of inaccuracies. The vibes of the description match the image but the actual details are definitely incorrect.&lt;/p&gt;

&lt;p&gt;This model downloaded 7.7GB to &lt;code&gt;~/.cache/huggingface/hub/models--microsoft--Phi-3.5-vision-instruct&lt;/code&gt; - significantly smaller than Llama 3.2's 20GB. I wonder if that size difference helps explain the greater hallucination rate in Phi-3.5 Vision.&lt;/p&gt;

&lt;p&gt;If you're running Python 3.10 on Apple Silicon you may be able to skip the Rust compiler by installing the wheel I built here:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install https://static.simonwillison.net/static/2024/mistralrs_metal-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
&lt;/code&gt;&lt;/pre&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/rust"&gt;rust&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mistral"&gt;mistral&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&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/meta"&gt;meta&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="microsoft"/><category term="python"/><category term="ai"/><category term="rust"/><category term="generative-ai"/><category term="llama"/><category term="local-llms"/><category term="llms"/><category term="mistral"/><category term="phi"/><category term="vision-llms"/><category term="meta"/></entry><entry><title>New Phi-3 models: small, medium and vision</title><link href="https://simonwillison.net/2024/May/21/phi-3-models-small-medium-and-vision/#atom-tag" rel="alternate"/><published>2024-05-21T20:04:30+00:00</published><updated>2024-05-21T20:04:30+00:00</updated><id>https://simonwillison.net/2024/May/21/phi-3-models-small-medium-and-vision/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.reddit.com/r/LocalLLaMA/comments/1cxa6w5/phi3_small_medium_are_now_available_under_the_mit/"&gt;New Phi-3 models: small, medium and vision&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I couldn't find a good official announcement post to link to about these three newly released models, but this post on LocalLLaMA on Reddit has them in one place: Phi-3 small (7B), Phi-3 medium (14B) and Phi-3 vision (4.2B) (the previously released model was Phi-3 mini - 3.8B).&lt;/p&gt;
&lt;p&gt;You can try out the &lt;a href="https://ai.azure.com/explore/models/Phi-3-vision-128k-instruct/version/1/registry/azureml"&gt;vision model directly here&lt;/a&gt;, no login required. It didn't do &lt;a href="https://twitter.com/simonw/status/1793009034863260035"&gt;a great job&lt;/a&gt; with my first test image though, hallucinating the text.&lt;/p&gt;
&lt;p&gt;As with Mini these are all released under an MIT license.&lt;/p&gt;
&lt;p&gt;UPDATE: Here's &lt;a href="https://github.com/microsoft/Phi-3CookBook/blob/main/md/01.Introduce/Phi3Family.md"&gt;a page from the newly published Phi-3 Cookbook&lt;/a&gt; describing the models in the family.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm-release"&gt;llm-release&lt;/a&gt;&lt;/p&gt;



</summary><category term="microsoft"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="phi"/><category term="llm-release"/></entry><entry><title>experimental-phi3-webgpu</title><link href="https://simonwillison.net/2024/May/9/experimental-phi3-webgpu/#atom-tag" rel="alternate"/><published>2024-05-09T22:21:48+00:00</published><updated>2024-05-09T22:21:48+00:00</updated><id>https://simonwillison.net/2024/May/9/experimental-phi3-webgpu/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://huggingface.co/spaces/Xenova/experimental-phi3-webgpu"&gt;experimental-phi3-webgpu&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Run Microsoft’s excellent Phi-3 model directly in your browser, using WebGPU so didn’t work in Firefox for me, just in Chrome.&lt;/p&gt;

&lt;p&gt;It fetches around 2.1GB of data into the browser cache on first run, but then gave me decent quality responses to my prompts running at an impressive 21 tokens a second (M2, 64GB).&lt;/p&gt;

&lt;p&gt;I think Phi-3 is the highest quality model of this size, so it’s a really good fit for running in a browser like this.

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


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/browsers"&gt;browsers&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/webassembly"&gt;webassembly&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/webgpu"&gt;webgpu&lt;/a&gt;&lt;/p&gt;



</summary><category term="browsers"/><category term="ai"/><category term="webassembly"/><category term="generative-ai"/><category term="local-llms"/><category term="llms"/><category term="phi"/><category term="webgpu"/></entry><entry><title>microsoft/Phi-3-mini-4k-instruct-gguf</title><link href="https://simonwillison.net/2024/Apr/23/phi-3-mini-4k/#atom-tag" rel="alternate"/><published>2024-04-23T17:40:16+00:00</published><updated>2024-04-23T17:40:16+00:00</updated><id>https://simonwillison.net/2024/Apr/23/phi-3-mini-4k/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf"&gt;microsoft/Phi-3-mini-4k-instruct-gguf&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Microsoft’s Phi-3 LLM is out and it’s really impressive. This 4,000 token context GGUF model is just a 2.2GB (for the Q4 version) and ran on my Mac using the llamafile option described in the README. I could then run prompts through it using the llm-llamafile plugin.&lt;/p&gt;

&lt;p&gt;The vibes are good! Initial test prompts I’ve tried feel similar to much larger 7B models, despite using just a few GBs of RAM. Tokens are returned fast too—it feels like the fastest model I’ve tried yet.&lt;/p&gt;

&lt;p&gt;And it’s MIT licensed.

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


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&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/local-llms"&gt;local-llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/phi"&gt;phi&lt;/a&gt;&lt;/p&gt;



</summary><category term="microsoft"/><category term="ai"/><category term="generative-ai"/><category term="local-llms"/><category term="llms"/><category term="llm"/><category term="phi"/></entry><entry><title>Microsoft Research relicense Phi-2 as MIT</title><link href="https://simonwillison.net/2024/Jan/6/relicense-phi-2-as-mit/#atom-tag" rel="alternate"/><published>2024-01-06T06:06:42+00:00</published><updated>2024-01-06T06:06:42+00:00</updated><id>https://simonwillison.net/2024/Jan/6/relicense-phi-2-as-mit/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://huggingface.co/microsoft/phi-2/commit/7e10f3ea09c0ebd373aebc73bc6e6ca58204628d"&gt;Microsoft Research relicense Phi-2 as MIT&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Phi-2 was already an interesting model—really strong results for its size—made available under a non-commercial research license. It just got significantly more interesting: Microsoft relicensed it as MIT open source.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://x.com/abacaj/status/1743500472520974364"&gt;@abacaj&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/microsoft"&gt;microsoft&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/open-source"&gt;open-source&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mitlicense"&gt;mitlicense&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/phi"&gt;phi&lt;/a&gt;&lt;/p&gt;



</summary><category term="microsoft"/><category term="open-source"/><category term="mitlicense"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="phi"/></entry></feed>