<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[2point0.ai]]></title><description><![CDATA[A blog for developers navigating the AI landscape, featuring hands-on tutorials, app reviews, and insightful exploration of the tech.]]></description><link>https://2point0.ai/</link><image><url>https://2point0.ai/icon-512.png</url><title>2point0.ai</title><link>https://2point0.ai/</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Feb 2025 15:43:36 GMT</lastBuildDate><atom:link href="https://2point0.ai/feed.xml" rel="self" type="application/rss+xml"/><item><title><![CDATA[Vibe coding]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/vibe-coding.CJ6jqZwg_Z1PKudG.webp" srcset="https://2point0.ai/_astro/vibe-coding.CJ6jqZwg_Z1PKudG.webp 1x,https://2point0.ai/_astro/vibe-coding.CJ6jqZwg_Z1PKudG.webp 2x" alt="Vibe coding" /><figcaption>Vibe coding</figcaption></figure><p>I like to think of myself as an “old-skool” dev - though let’s be honest, that’s just a hip way of saying I’m an old dev that’s been writing code since another millennium.</p>
<p>It wasn’t that long ago that professionals working on the web would describe their work using the language of a “craftsman”. We were digital artisans, building pixel perfect designs, creating delightful digital experiences and shipping hand-crafted code that we were proud of.</p>
<p>These days developers have a new language that captures the zeitgeist of the modern AI engineer: <a href="https://x.com/karpathy/status/1886192184808149383">Vibe coding</a>.</p>
<figure>
    <img src="/images/2025/karpathy-vibe-coding.webp" alt="@karpathy on Vibe Coding">
    <figcaption class="sr-only" aria-hidden="">
        <blockquote>
            <p>There's a new kind of coding I call "vibe coding", where you fully give in to the vibes, embrace exponentials, and forget that the code even exists. It's possible because the LLMs (e.g. Cursor Composer w Sonnet) are getting too good. Also I just talk to Composer with SuperWhisper so I barely even touch the keyboard. I ask for the dumbest things like "decrease the padding on the sidebar by half" because I'm too lazy to find it. I "Accept All" always, I don't read the diffs anymore. When I get error messages I just copy paste them in with no comment, usually that fixes it. The code grows beyond my usual comprehension, I'd have to really read through it for a while. Sometimes the LLMs can't fix a bug so I just work around it or ask for random changes until it goes away. It's not too bad for throwaway weekend projects, but still quite amusing. I'm building a project or webapp, but it's not really coding - I just see stuff, say stuff, run stuff, and copy paste stuff, and it mostly works.</p>
            <footer>
                Posted by <a href="https://x.com/karpathy/status/1886192184808149383">@karpathy</a>
            </footer>
        </blockquote>
    </figcaption>
</figure>
<p>Karpathy goes on to describe vibe coding in practice as some kind of slider.</p>
<div data-callout="" data-callout-type="quote">
<div data-callout-title=""><a href="https://x.com/karpathy/status/1886193527224517106">@karpathy</a></div>
<div data-callout-body="">
<p></p>
<p>All the way on the left you have programming as it existed ~3 years ago. All the way on the right you have vibe coding.</p>
</div>
</div>
<p>I like the slider analogy and see this as a transition from craft to vibes. It’s the modern day equivalent of when textile work shifted from a highly skilled craft to an entirely automated process. The transition didn’t occur overnight, but one <a href="https://en.wikipedia.org/wiki/Spinning_jenny">Spinning Jenny</a> here and a <a href="https://en.wikipedia.org/wiki/Jacquard_machine">Jacquard Loom</a> there, and the next thing you know the craft of textile working is no more. The march of progress is inexorable, and we’ve seen that transition repeat many times through history.</p>
<p>But where exactly are we on this slider? And if I can stretch the analogy even further, if our slider is a DJ’s cross-fader, are we in for a quick chop, or is this going to be a long fade mix?</p>
<p><img src="https://2point0.ai/images/2025/cross-fader.jpg" alt="Vibe slider"></p>
<h2 id="current-state-of-play">Current state of play</h2>
<p>I recently spent a few days with a company that are cranking that vibe slider as far as they can. They’re building their own agent tooling that will take a boilerplate app and spec, and use AI to create a fully functioning app in 15 to 30 minutes.</p>
<p>It’s really impressive to watch an agent loop over the spec and iterate on the build step by step. What they’ve built so far is great, and one of their generated apps has been out in the wild for a while and is already generating revenue.</p>
<p>But… their generated apps are still what you might consider (and I’m quoting their CEO here), <em>“shitty little apps”</em>. We’re talking single feature apps - a small database, user auth, a handful of routes and a couple of endpoints. For a competent dev, it’s the kind of thing you could bash out in a day or two.</p>
<p>I can pick other bones too. When the agents struggle with a more complex feature, what they’re typically doing is hand writing the code and wrapping it in a function so the AI-generated code can implement the feature just by calling a function. That’s a totally pragmatic thing to do, but we’re already edging that slider back towards craft coding.</p>
<p>I think what this company is doing is really cool, and their ambition is far greater than shitty little apps. But I mention all this because I think it reflects the messy reality of vibe coding. Anyone who’s used Cursor for anything more complex than a one-shot Flappy Bird clone will know there’s a lot of effort involved in prompting, providing context, and testing and validating outputs. Without a skilled human pulling the strings, the vibes can get ugly, quickly.</p>
<h2 id="prompting-and-context-challenges">Prompting and context challenges</h2>
<p>Prompting isn’t just about describing a task or instruction. Agents need to know everything about your codebase in quite a lot of detail. They need to know the stack, the key dependencies, and they need to see lots of examples of how you actually want them to code.</p>
<p>And as a project and its architecture evolves, so too must the prompts and fragments of prompts that your agents depend on. Managing all of this is quite a lot of effort. Being able to prompt clearly and effectively is a skill that not every developer is going to be blessed with. But for vibe coding, it’s an essential.</p>
<p>There are <a href="https://cursorlist.com/">sites popping up</a> for users to share <code>.cursorrules</code> files for different stacks, and some developer tools and libraries are starting to share <a href="https://supabase.com/docs/guides/getting-started/ai-prompts">prompt fragments in their documentation</a>. This is all great to see and does help the vibe coder find their way in all this.</p>
<p>Context management poses another challenge. In principle, agents work better when they are shown the right context at the right time, and not necessarily all the context all the time. Ideally, IDEs would make this <em>just work™</em>, but in practice this is tricky stuff to get right and another messy aspect of vibe coding that developers need to grapple with.</p>
<h2 id="validation-challenges">Validation challenges</h2>
<p>When we’re writing code ourselves, we inherently validate our work as we go. But with vibe coding, validation becomes a critical challenge that can make or break the entire approach. We can either fly blind, or we can implement robust validation strategies and take advantage of <a href="https://x.com/jonas/status/1879573296913756389">mathematics and probability</a>.</p>
<figure>
    <img src="/images/2025/jonas-probability.webp" alt="@jonas on Probability">
    <figcaption class="sr-only" aria-hidden="">
        <blockquote>
            <p>If an AI agent gets a task (say, building an app) right only 1/10 times, it means that with enough money it can get it right 99.99% of the time.</p>
            <p>For that to work, though, the agent needs good validators that tell it whether it did the right thing.</p>
            <footer>
                Posted by <a href="https://x.com/jonas/status/1879573296913756389">@jonas</a>
            </footer>
        </blockquote>
    </figcaption>
</figure>
<p>The idea here is if an agent succeeds only 10% of the time, if you run enough of those agents (88 I think, but someone brainier than me can explain the maths), then there’s a 99.9% chance at least one of them succeeds.</p>
<p>All that depends on having good tests and checks in place to determine when an agent gets it right. There’s some low-hanging fruit here: your agents should definitely be seeing your Typescript compile errors and linter warnings for a start.</p>
<p>And then there’s testing. In a vibe coding maximalist world the AI will write the tests too, but for now this is a role for developers whilst they push the vibe slider as far as they’re comfortable with.</p>
<h2 id="ui-and-ux-challenges">UI and UX challenges</h2>
<p>If moving the vibe coding slider to the right comes at a cost, by far the greatest cost in my view, is the detrimental effect on quality of design and user experience.</p>
<p>Whilst agents can do a reasonable job throwing components together using frameworks like shadcn and similar, let’s be honest, AI-gen design is always very, very average. We’re talking functional but uninspired layouts, predictable typography and color schemes that you know you’ve seen a thousand times over. It’s bland, generic, just “meh” kinda stuff.</p>
<p>Sometimes that’s fine. If it’s a private or internal project, we can make these kinds of compromises. But for a real, consumer facing, commercial app, I think the vibe coder falls well short of any craft coder with good design chops.</p>
<p>There’s a missing piece here: not just models that have visual understanding, but models that are specifically trained on decades of examples of great design and can review and can improve their own code from a UX point of view.</p>
<p>I’m sure somewhere there are some smart people working on exactly that, but for now I think vibe coders just fundamentally don’t have the tools for doing good design and UX.</p>
<h2 id="the-times-they-are-a-changin">The times, they are a changin’</h2>
<p>The software engineer, as a role, is well and truly in the mix. You can hear the beat - DJ Vibes is moving that slider from left to right. But I don’t think we’re quite as far into the transition as <a href="https://x.com/shl/status/1887484068075274347">others seem to think</a>.</p>
<figure>
    <img src="/images/2025/sahil-junior-devs.webp" alt="@shl on Junior Devs">
    <figcaption class="sr-only" aria-hidden="">
        <blockquote>
            <p>No longer hiring junior or even mid-level software engineers.</p>
            <p>Our tokens per codebase:</p>
            <p>
                Gumroad: 2M<br>
                Flexile: 800K<br>
                Helper: 500K<br>
                Iffy: 200K<br>
                Shortest: 100K
            </p>
            <p>Both Claude 3.5 Sonnet and o3-mini have context windows of 200K tokens, meaning they can now write 100% of our Iffy and Shortest code if prompted well.</p>
            <p>Our new process:</p>
            <p>
                1. Sit and chat about what we need to build, doing research with Deep Research as we go.<br>
                2. Have AI record everything and turn it into a spec.<br>
                3. Clean up the spec, adding any design requirements / other nuances.<br>
                4. Have Devin code it up.<br>
                5. QA, merge, (auto-)deploy to prod.
            </p>
            <footer>
                Posted by <a href="https://x.com/shl/status/1887484068075274347">@shl</a>
            </footer>
        </blockquote>
    </figcaption>
</figure>
<p>Sahil’s post doesn’t really pass the sniff test. Not withstanding the obvious fact that if you don’t have junior devs, then it isn’t long until you don’t have senior devs either, I simply don’t think the tooling and models are ready for this. But as a vision for what a maxed out vibe coding environment looks like… maybe?</p>
<p>I still <a href="https://2point0.ai/posts/reports-of-codings-death-are-greatly-exaggerated">don’t believe coding is dead</a>, and I don’t believe junior or mid level devs are done for, but I do believe this slide to the right is in play. The role of a developer or software engineer, across all levels, is fundamentally changing. Whilst we can dream of sitting around on beanbags, chatting, and brainstorming while the agents do the coding, the reality is we’re trading writing code for wrestling with prompts, managing context, and writing many, many tests and validators.</p>
<h2 id="conclusions-any">Conclusions… any?</h2>
<p>The slide from craft to vibes isn’t a clean transition - it’s messy, complex, and full of hard problems that need to be solved - and we’re still very much in the early days of this transition.</p>
<p>The reality is that effective vibe coding today requires a peculiar mix of skills: traditional coding expertise, prompt engineering finesse, and a willingness to test outputs far more vigorously than you’d test your own outputs. It’s less about replacing development skills and more about augmenting them with new tools and approaches.</p>
<p>Just as the industrial revolution was a more gradual transition than the age’s technological advancements suggested - a transition limited by the practical realities of human adaptation - the shift to vibe coding will likely be just as nuanced. The greatest opportunities will come to those who can navigate this gap between AI capability and human readiness.</p>
<p>For now, the slider sits closer to craft than vibes. The future may yet bring Sahil’s vision of developers as spec-writers and AI-wranglers into reality, but the path there isn’t as straight or as short as some might suggest. The beat goes on, the mix continues, and somewhere between craft and vibes, we’ll find our groove.</p>]]></description><link>https://2point0.ai/posts/vibe-coding</link><guid isPermaLink="false">d3d3a82e-8492-5af9-84c2-40104fcbd104</guid><pubDate>Wed, 12 Feb 2025 00:00:00 GMT</pubDate></item><item><title><![CDATA[Announcing Agentflow]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/agentflow-banner.CQOrsD8e_MchNv.webp" srcset="https://2point0.ai/_astro/agentflow-banner.CQOrsD8e_MchNv.webp 1x,https://2point0.ai/_astro/agentflow-banner.CQOrsD8e_MchNv.webp 2x" alt="Announcing Agentflow" /><figcaption>Announcing Agentflow</figcaption></figure><p>I’m very pleased to announce the launch of <a href="https://agentflow.2point0.ai">Agentflow</a> - a powerfully simple AI agent framework.</p>
<p>Agentflow enables developers to create AI workflows that read like documentation but execute like code. By combining natural language with minimal markup, you can compose complex agent behaviours using plain English as your main programming language.</p>
<p>The framework provides all the structure and control you’d expect from traditional programming but is expressed in an intuitive Markdown-based format that puts readability first.</p>
<h2 id="not-another-one-why"><em>Not another one</em>. Why?</h2>
<p><img src="https://2point0.ai/images/2024/not-another-one.webp" alt="Not another one!"></p>
<p>The path to Agentflow began with a simple frustration. I am not a Python developer. Frameworks like CrewAI and LangChain dominate the AI agent space, but I found myself wanting similar tooling using languages I was more comfortable with and that better suited my development style.</p>
<p>I’ve also noticed a trend that many agent frameworks are quite complex and enterprise-focused. I didn’t want to set up servers and infrastructure; I just wanted something lightweight and easy that I could hack around with on my own computer.</p>
<p>Not too many moons ago I shared <a href="https://2point0.ai/posts/meet-the-news-shift">my work on Shifts</a>, an Elixir-based agent framework inspired by CrewAI. I definitely learnt some lessons building Shifts, but it didn’t feel like I’d nailed it. So, I put it down to think about the problem again.</p>
<p>There’s an old <a href="https://x.com/karpathy/status/1617979122625712128">tweet from Andrej Karparthy</a> that simply says, “The hottest new programming language is English”. I love that idea, and it got me thinking… What if we could create a framework that embraces that idea, and puts the human intent front and centre? Rather than bringing prompts into code, could we somehow make the prompts the code? This thinking led directly to what would become Agentflow.</p>
<h2 id="what-makes-agentflow-different">What makes Agentflow different?</h2>
<p>From the start, Agentflow embraces natural language as its primary input. Instead of constructing agents with code that contains prompts, with Agentflow you write prompts that contain minimal code. This makes the composition of agents simpler, but more importantly, it puts human intent front and centre of the development process.</p>
<p>Workflows are written using a variation of Markdown similar to <a href="https://mdxjs.com/docs/what-is-mdx">MDX</a> (in fact, it uses the MDX parser internally). The result is a format that is as readable as plain text and with enough structure to implement loops, conditional branching and call actions inside the workflow.</p>
<p><img src="https://2point0.ai/images/2024/agentflow-example.webp" alt="Example workflow in Agentflow"></p>
<p>Staying true to this text-first philosophy, Agentflow operates entirely through a command-line interface - no GUI required. It’s lightweight and easy to install, with no infrastructure or cloud requirements. You can <a href="https://agentflow.2point0.ai/guide/getting-started.html">get everything up and running on your machine</a> in under a minute.</p>
<p>Under the hood, Agentflow is powered by Vercel’s excellent <a href="https://sdk.vercel.ai">AI SDK</a>. This means baked-in support for any AI provider supported by the SDK (that’s pretty much all of them), and agents can use any third-party tools compatible with AI SDK. The result is a framework that is as capable as it is approachable, whether building simple automations or sophisticated AI-powered workflows.</p>
<h2 id="looking-ahead">Looking ahead</h2>
<p>Agentflow is still in its early stages and there’s a lot of work ahead. Like any new software, there will be bugs to fix, rough edges to smooth out, and for now the design and APIs are all subject to change as I learn how people use Agentflow out in the wild.</p>
<p>And that’s exactly why I’m releasing Agentflow now. I want to see how people use it, learn from their experiences, and understand what they need. All feedback is valuable at this stage, whether it’s bug reports or feature requests. While there are clear areas for improvement, such as expanding the collection of first-party tools, or thinking carefully about security when users start sharing workflows and actions, the exact direction will be influenced by users’ needs and experiences.</p>
<p>My hope for Agentflow is simple: I want to make it easier for anyone to start experimenting with and building AI agents. Whether you’re an experienced developer or a weekend-only hacker and tinkerer, Agentflow’s JavaScript foundations and natural language programming should feel intuitive and accessible. I’m excited to see what people build with it, how they extend it, and where they take it.</p>
<h2 id="get-building">Get building</h2>
<p>Ready to try Agentflow? Head over to the <a href="https://agentflow.2point0.ai">Agentflow docs</a> - the <a href="https://agentflow.2point0.ai/guide/getting-started.html">getting started guide</a> will walk you through installation and creating and running your first workflow.</p>
<p>For those interested in reporting bugs, getting involved, or just reading the source code, head over to the <a href="https://github.com/lebrunel/agentflow">Agentflow repository</a> on GitHub.</p>
<p>I’m looking forward to seeing what you build with it!</p>]]></description><link>https://2point0.ai/posts/announcing-agentflow</link><guid isPermaLink="false">31ed4fae-6ce9-5812-9a9a-0451150207ed</guid><pubDate>Tue, 17 Dec 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Zed AI review: Getting the balance right in AI code editing]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/zed-ai-review.BJNignXu_Z1PN6Sb.webp" srcset="https://2point0.ai/_astro/zed-ai-review.BJNignXu_Z1PN6Sb.webp 1x,https://2point0.ai/_astro/zed-ai-review.BJNignXu_1GBGUK.webp 2x" alt="Zed AI Review" /><figcaption>Zed AI Review</figcaption></figure><p>Developers are unwaveringly loyal when it comes to their choice of code editor. Just ask anyone who’s spent the time and energy needed to master vim… that’s a path they will never turn back from.</p>
<p>For developers, switching code editor is a rare - almost epochal - event. My own journey from Dreamweaver (yep!) to Sublime Text to VS Code is one that played out over 20 years. But recently, with AI becoming an essential part of many developers’ tool kits, a new generation of code editors that place AI front and centre of the developer experience are emerging to shake up the status quo.</p>
<p>Whilst Cursor has been grabbing <a href="https://www.cursor.com/blog/series-a">all the headlines</a>, it is far from the only player in town. Last month, <a href="https://zed.dev/blog/zed-ai">Zed announced Zed AI</a>, its own AI-assisted coding tools packaged within an already impressive code editor.</p>
<p>For the past few weeks I have been using Zed as my daily driver. This article won’t be a full review of Zed, but I will share my experiences and impressions of Zed’s AI features after a month of pretty heavy use. Is this one of those epochal moments? Will I be switching for good? Read on to find out.</p>
<h2 id="what-is-zed">What is Zed?</h2>
<p>I first came across Zed earlier this year when I noticed a few developers in the Elixir community speaking highly of it. Launched in 2023, Zed is founded by <a href="https://zed.dev/team">the team</a> who built the GitHub Atom editor. In Zed, they’ve built a fast, modern code editor. It uses its own highly performant rendering engine built with Rust, and Zed has been steadily winning fans by focussing on the developer experience and getting the basics right.</p>
<p>The introduction of AI features adds to Zed’s previous attention to collaborative chat and pair-programming features. I’m unsure if this represents a slight pivot in plan, but either way Zed AI turns Zed from an interesting looking editor that didn’t quite have enough to peel me away from VS Code a few months ago, into an editor that I definitely want to take for a spin now.</p>
<h2 id="zed-ai-features">Zed AI features</h2>
<p>Zed’s AI offering can broadly be split into three main features:</p>
<ul>
<li>The <strong>assistant panel</strong> for chatting with AI about your code.</li>
<li>The <strong>inline assistant</strong> for using AI to directly transform your code.</li>
<li>Slash style <strong>assistant commands</strong> for injecting additional context into your chats and interactions.</li>
</ul>
<p>Let’s take a look at each:</p>
<h3 id="assistant-panel">Assistant panel</h3>
<p>At a glance, the assistant panel looks and feels like every other AI chat interface you’ve ever used. But it’s definitely not quite like <em>any</em> other chat interface. The entire chat - what Zed calls a “context” - is one continuous text file that feels the same as working with any other text file in Zed. You can move the cursor anywhere, work with multiple cursors, use key bindings, and so the process of adding bits of code to your context feels completely natural and seamless.</p>
<p><img src="https://2point0.ai/images/2024/zed-assistant-panel.webp" alt="Zed Inline Assist"></p>
<p>There is keyboard shortcut (<code>cmd-></code>) for inserting selected text from the main editor into the assistant panel in a fenced code block. There is also a range of slash commands (which we’ll explore a bit further below) for injecting code into your context - for example an entire file or directory of files. These injected elements appear in the assistant panel as a toggle-able element that can be expanded in full or minimised, so your focus can remain on your prompt.</p>
<p>When you’re ready, hitting <code>cmd-enter</code> submits your context and the AI assistant streams a response to the bottom of the context.</p>
<p>One useful side effect of the entire context being an editable buffer of text is that it’s trivial to “rewrite history” by removing or editing previous parts of the conversation. You can fork an entire context by simply copying and pasting the entire thing into a new context and taking the same base conversation in two different directions.</p>
<p>I’m not aware of any other chat UI working quite like this, and so the Zed team deserve some applause here. They’ve nailed the UX, and I find myself wanting to do other, non-coding tasks in Zed (for example, writing drafts for this blog) purely because I love the experience of flipping to and from the assistant panel so much.</p>
<h3 id="inline-assistant">Inline assistant</h3>
<p>Wherever you can select text - the main editor, the terminal, even the assistant panel - you can invoke the inline assistant and prompt it to directly transform your selected code.</p>
<p>When you invoke the inline assistant (<code>ctrl-enter</code>), if you also have the assistant panel open, that is provided as context in addition to your inline prompt. That’s not totally intuitive, but once you understand that’s the way it works it’s a powerful way to combine a detailed prompt as context with a simple inline instruction.</p>
<p><img src="https://2point0.ai/images/2024/zed-inline-assist.webp" alt="Zed Inline Assist"></p>
<p>The transformed code is then presented to you as a diff which you can either accept or reject. You can also use multiple cursors and highlight multiple selections to invoke inline assistant in several places at the same time. I use this all the time for adding doc blocks to functions.</p>
<p>One recipe in the Zed docs for fixing errors is to create a new context in the assistant panel, use the <code>/diagnostics</code> and <code>/terminal</code> commands to inject diagnostics and error logs into the context, select the misbehaving code and use inline assistant to generate a fix. It works wonderfully.</p>
<h3 id="assistant-commands">Assistant commands</h3>
<p>Within the assistant panel, you can hit forward slash (<code>/</code>) to bring up a list of available commands. These commands effectively inject content from your code or elsewhere in the editor into the current context.</p>
<p>For example, the <code>/diagnostics</code> command will inject any output and warnings from the language server; the <code>/file</code> command allows you to select a file or folder of files to insert into the context; and the <code>/fetch</code> command injects the response of a HTTP request. All the built-in commands are listed in the <a href="https://zed.dev/docs/assistant/commands">Zed docs</a>.</p>
<p>If the built-in commands don’t serve all your needs, you can create your own. Well, apparently you can. Documentation is a bit thin here so I haven’t tried to create a custom slash command, but in theory this could be a very powerful way to inject context from other sources, such as documentation, websites and APIs, or other local files.</p>
<p>One command worth special mention is <code>/workflow</code>. If you invoke it and expand the toggle, it reveals a giant system prompt that instructs the LLM to guide the user through a series of stepped changes and respond in a very specific, structured format. The assistant panel then recognises this structure and presents the “steps” with a UI where you can work through the changes step by step.</p>
<p><img src="https://2point0.ai/images/2024/zed-workflow.webp" alt="Zed Workflow Command"></p>
<p>You can see where they’re going with this. This brings Zed closer to Cursor’s Composer view, where you can work with the assistant iteratively to build out a specific feature or refactor purely through prompting. In my testing, I couldn’t really get <code>/workflow</code> to work reliably. It would produce a multistep workflow which had “step resolution errors”, or some steps would repeat or conflict with previous steps. It’s a promising looking feature, but in practice feels like you need to cross all your fingers and make a sacrifice to the AI gods if you want it to actually work.</p>
<h2 id="what-do-developers-want-from-ai-in-code-editors">What do developers want from AI in code editors?</h2>
<p>I know quite a few experienced software developers who are either irrationally anti-AI, or just apathetic towards AI. On the flip side, many younger developers are attracted to the idea of a prompt-driven, no-code software development process - just see all the <em>“How I used Cursor to build this [INSERT APP/GAME] clone in MINUTES”</em> videos doing the rounds on social media.</p>
<p>Needless to say, I think both these takes are missing the mark. The real gains of using AI in software development come from a more nuanced middle ground.</p>
<p>I use AI every single day for things like:</p>
<ul>
<li>Thinking through a problem, and comparing and evaluating different high-level solutions.</li>
<li>Writing enough code to “show me the way” so that I can pick up a pseudo implementation and use it in a way more specific to my code base.</li>
<li>Fixing errors by sharing the error and the code and letting AI generate the fix.</li>
<li>Chores like writing unit tests and adding code documentation and annotations.</li>
</ul>
<p>What I don’t expect or want AI to do is write every single line of code in my app or product. I can’t see how it’s possible for that to happen without myself being so disconnected from the process that I no longer feel I can influence, or be responsible for, the quality (or lack of) of the code. Even if the models get better over time, and I expect they will, I feel this is a misguided aspiration that will result in worse developers, worse code and worse products.</p>
<p>So for now, the flashy, whizz-bang Cursor demos don’t really impress me, and don’t reflect what I’m looking for in an AI coding assistant.</p>
<h2 id="zed-improves-the-dev-experience-with-balanced-ai-features">Zed improves the dev experience with balanced AI features</h2>
<p>Which brings us back to Zed. How does it really stack up?</p>
<p>First off, before we even start talking about AI, Zed is a solid, modern and very fast code editor that gets the basics right. Being a new editor, it’s not without bugs, but I didn’t come across anything other than minor UX/UI annoyances. It also lacks support for one or two more niche language syntaxes, but all popular languages are well-supported.</p>
<p>Zed’s AI features are refined and thought through. The UX of the assistant panel feels integrated and seamless. Treating the entire chat “context” as one giant text file feels so natural. And when we need to inject context, the built-in slash commands are simple, intuitive and work perfectly.</p>
<p>When you need AI to directly transform your code, the inline assistant works great. Combining the assistant panel with multiple cursors and inline assistants allows for some pretty powerful and efficient workflows.</p>
<p>One thing Zed doesn’t have is AI tab autocompletion. I know some people love it, but I’ve always felt that’s like Russian Roulette coding.</p>
<p>And this is why I say Zed’s AI features feel thought through. Has tab autocomplete been omitted because they just haven’t built it yet, or did they weigh up how much value these features add to the developer experience first? I get the feeling it’s the latter.</p>
<p>I’m sure they will add more AI over time - the <code>/workflow</code> command feels very much like a work in progress, and it will be hard to resist trying to keep up with the more AI-centric approach of Cursor over time. But I hope and trust Zed keep their focus on developers and the developer experience. At the moment, they’re striking the balance well.</p>
<p>Zed’s hosted AI features are powered by Claude and are currently available for free. I presume that won’t always be the case, but there are no details currently on pricing. However, it’s also possible to add your own API keys for whatever AI providers you fancy, including Anthropic. So if and when it becomes a paid service, you should be able to run with your own keys if preferred. This, at least to me, makes it a more attractive prospect than Cursor where the only option is a subscription.</p>
<h2 id="conclusion">Conclusion</h2>
<p>So, after a month of use, are we witnessing the beginning of a new epoch? Is VS Code now destined to gather dust in my dock whilst Zed gets all the attention? The answer is, <strong>yes</strong>!</p>
<p>I’m genuinely loving using Zed, and the way it’s AI features are designed and integrated feel just right for <em>me</em> and what I wish from AI at this time.</p>
<p>But… here’s the catch. I’ve compared Zed to Cursor a few times in this article, and I’ve poured a bit of scepticism on the whole <em>“I built Notion in minutes”</em> thing… but I’m not being entirely fair here because I’ve not tried Cursor to the extent that I’ve been using Zed this past month.</p>
<p>So, my challenge for October is to put Cursor through its paces too. We will see if it wins me over or changes my view on exactly what kind of AI features I think I need. So stay tuned, subscribe to <a href="https://2point0.ai/feed.xml">the feed</a> and <a href="https://x.com/aaronrussell">follow me on X</a> to be the first to read my Cursor review next month.</p>]]></description><link>https://2point0.ai/posts/zed-ai-review</link><guid isPermaLink="false">21bf1c96-57e4-5b72-8db4-7825ce6cc890</guid><pubDate>Fri, 20 Sep 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[California's AI safety bill has passed. What does it mean for open source AI?]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/ai-safety-bill.prUb6Hz3_1hSgbW.webp" srcset="https://2point0.ai/_astro/ai-safety-bill.prUb6Hz3_1hSgbW.webp 1x,https://2point0.ai/_astro/ai-safety-bill.prUb6Hz3_1hSgbW.webp 2x" alt="SB-1047 AI safety bill" /><figcaption>SB-1047 AI safety bill</figcaption></figure><div data-callout="" data-callout-type="info">
<div data-callout-title="">SB-1047 vetoed</div>
<div data-callout-body="">
<p></p>
<p>On 29 September 2024, one month after publishing this article, Governor Gavin Newsom vetoed SB-1047, citing the “chilling effect” the bill could have on the competitiveness of California’s AI industry.</p>
</div>
</div>
<p>It’s finally happened - California’s <a href="https://leginfo.legislature.ca.gov/faces/billTextClient.xhtml?bill_id=202320240SB1047">AI safety bill (SB-1047)</a> was <a href="https://www.theverge.com/2024/8/28/24229068/california-sb-1047-ai-safety-bill-passed-state-assembly-governor-newsom-signature">passed by the State Legislature</a>. The bill now sits on Governor Gavin Newsom’s desk and is one rubber stamp away from becoming law.</p>
<p>So, I guess that’s it? Time to pack up and move onto something else… I mean, for months the AI chattering classes have been telling us how <a href="https://time.com/collection/time100-voices/7016134/california-sb-1047-ai/">disastrous this bill will be</a>, how it will restrain innovation and kill off open source AI.</p>
<p>Well, not so fast. You see, this story is as old as the hills. Every new and disruptive technology faces similar scrutiny. The legislators have heard all the arguments on both sides a thousand times over, and their job is to strike a balance of protecting society without dampening innovation.</p>
<p>So, now that the act is a formality away from becoming law, let’s take a step back and look at what this bill <em>really</em> means for AI. In this article I’ll offer me layman’s interpretation of what the act covers (and doesn’t cover), and what the real world implications for AI will be, particularly open source AI.</p>
<h2 id="what-is-sb-1047">What is SB-1047</h2>
<p>To give the bill it’s full name, SB-1047 is the <em>“Safe and Secure Innovation for Frontier Artificial Intelligence Models Act”</em>. The purpose of the bill is to ensure safe and secure innovation for frontier artificial intelligence models in California.</p>
<p>The legislation is of global significance because AI is a highly disruptive emerging technology and the laws are playing catch up. Regulators around the World are watching California carefully, and this bill will likely set in motion a precedence that other states and countries will follow.</p>
<p>And, if you take the view as I do, that AI represents a new industrial age, then the US getting this wrong could hand its technological lead to its competitors, with geopolitical consequences.</p>
<p>With the stakes so high, it’s natural that those in the AI industry are anxious of premature-regulation. Of course, the devil is in the details, so let’s dive into it and explore some of the nuance that is often missed in discussion.</p>
<h2 id="breaking-down-the-bill">Breaking down the bill</h2>
<p>First of all, this bill sets out a couple of crucial definitions that define the scope and purpose of the bill.</p>
<h3 id="covered-models">”Covered models”</h3>
<p>The bill defines specific thresholds for what models are covered:</p>
<ul>
<li>An AI model trained using computing power greater than 10^26 floating point operations (FLOPS), with a cost exceeding $100 million.</li>
<li>OR, a model created by “fine-tuning” a covered model using computing power greater than 10^25 FLOPS, with a cost exceeding $10 million.</li>
</ul>
<p>10^26 is a number with more zeros than my brain can handle, but $100 million I can just about cope with. It’s a <strong>lot</strong> of money.</p>
<h3 id="critical-harm">”Critical harm”</h3>
<p>The bill provides a specific definition of “critical harm”, as any of the following harms “materially” enabled by a covered model.</p>
<ul>
<li>The creation or use of chemical, biological, radiological, or nuclear weapons resulting in mass casualties.</li>
<li>Mass casualties or at least $500 million of damage resulting from cyberattacks on critical infrastructure.</li>
<li>Mass casualties or at least $500 million of damage resulting from an AI model acting with limited human oversight that would constitute a crime if committed by a human.</li>
<li>Other grave harms to public safety and security of “comparable severity” to the above.</li>
</ul>
<p>The bill also explicitly excludes:</p>
<ul>
<li>Harms caused by information that is otherwise reasonably publicly accessible.</li>
<li>Harms caused by a covered model combined with other software if the covered model didn’t materially contribute to the harm.</li>
</ul>
<p>The thresholds for both definitions get reviewed after 1 January 2027, and monetary amounts adjusted annually for inflation.</p>
<p>These two thresholds quite clearly show that this is a bill designed to capture very large, very powerful AI models, and is specifically focused on severe, large scale harms like terrorist events or cyberattacks on critical infrastructure.</p>
<h3 id="requirements-for-developers">Requirements for developers</h3>
<p>The bill outlines several requirements fort developers of covered models:</p>
<ul>
<li>Developers must register their covered models with the California Department of Technology.</li>
<li>Comprehensive evaluations must be conducted to identify potential critical harms.</li>
<li>Appropriate measures must be implemented to prevent unauthorised access, misuse, or unsafe modifications of the model.</li>
<li>Any critical harms or near misses must be promptly reported to the authorities.</li>
<li>Developers must maintain the ability to cease operation of the model if necessary to prevent critical harm.</li>
</ul>
<p>As well as creating lots of paperwork for everyone involved, these requirements aim to ensure responsible development and deployment of frontier models, while maintaining transparency and accountability.</p>
<h3 id="what-sb-1047-is-not">What SB-1047 is not?</h3>
<p>I suspect most people would agree that ensuring terrorists can’t use AI to learn how to build and use biological weapons is, on balance, a good thing. But, I also think people have more immediate concerns about AI. Things like:</p>
<ul>
<li>Mass unemployment and re-skilling in the face of automation.</li>
<li>The environment and the huge amounts of energy consumed by training AI models.</li>
<li>Copyright issues and the industrial scraping of internet data for training AI models.</li>
<li>Easy access to tools that can create highly realistic deep-fakes and deceiving images.</li>
</ul>
<p>Guess what? SB-1047 has nothing to say about any of that. The bill is as minimal in its scope as you could expect. I mean, if you don’t draw the red line at chemical and nuclear weapons, then where do you?</p>
<h2 id="impacts-on-open-source-ai">Impacts on open source AI</h2>
<p>Whilst SB-1047 does not specifically prohibit open weight models, it creates a regulatory environment that could discourage developers of covered models from releasing them openly. For example:</p>
<blockquote>
<p>“the developer shall […] prevent unauthorized access to, misuse of, or unsafe post-training modifications of the covered model”</p>
</blockquote>
<blockquote>
<p>the developer shall […] implement appropriate safeguards to prevent the covered model and covered <strong>model derivatives</strong> from causing or materially enabling a critical harm</p>
</blockquote>
<blockquote>
<p>a developer shall not […] make a covered model or a covered model derivative available for commercial or public, or foreseeably public, use, if there is an unreasonable risk that the covered model or covered model derivative will cause or materially enable a critical harm</p>
</blockquote>
<p>Taken at face value, these provisions seem to be incompatible with a fully open release. Developer’s of closed models can design safeguards into their own systems and infrastructure, but once a model is out in the wild the developers lose all practical control - and they suddenly become liable for the actions of others.</p>
<h3 id="safeguarding-ai-is-hard">Safeguarding AI is hard</h3>
<p>You might be thinking, why can’t the models just be released without the capability of teaching us how to do things like build biological weapons in the first place?</p>
<p>It seems a reasonable question. After all, a model just reflects its training data, so just don’t train it on the bad stuff, right? Unfortunately, it’s not as simple as that.</p>
<ul>
<li>Large language models can develop emergent capabilities they weren’t explicitly trained for. They can combine information in novel and unpredictable ways, leading to unexpected capabilities.</li>
<li>Much information that could be used for harmful purposes, also has legitimate uses. For example, knowledge about chemistry or biology that could be used for important medical breakthroughs, could also be used to create weapons.</li>
<li>The sheer vastness of possible inputs and outputs makes it practically impossible to anticipate all potential harmful uses.</li>
<li>Users will always try (and often succeed) in circumventing trained in safety measures through clever prompting techniques.</li>
<li>Some potential harms, such as cyberattacks, don’t even require any specific “dangerous” training data to be a threat.</li>
</ul>
<p>There is a whole area of research around “model alignment”. Ensuring AI systems behave in ways that are aligned with human values and intentions is complex and not fully solved.</p>
<p>The bill recognises these complexities and so focuses on risk assessments, monitoring and auditing, and the ability to “shut down” the model. All of which becomes very difficult once that model is released openly and out in the wild.</p>
<h3 id="is-this-regulatory-capture">Is this regulatory capture?</h3>
<p>It’s worth noting that as it stands today, there probably isn’t any open-weight model that would fall within the act’s definition of a “covered model”. Even Llama 3.1 405B (the largest open weight model to date) <a href="https://x.com/astonzhangAZ/status/1815763885380747422">probably falls short</a>.</p>
<p>But, it’s not far off. And there must now be question marks over whether Meta will ever release an even larger model openly.</p>
<p>Time will tell, and there’s certainly enough <em>“unreasonable risk”</em> and <em>“materially contribute”</em> type language in the bill to give Meta’s lawyers something to chew on.</p>
<p>But, if this does discourage future frontier models being released openly, then that’s a scenario that clearly benefits the developers of closed, proprietary models, and all but closes the door to new entrants to the market. That would point towards a future where access to the very best and most powerful AI models is exclusively controlled by a handful of all-powerful tech giants.</p>
<h2 id="winners-and-losers">Winners and losers</h2>
<p>At first glance, SB-1047 might seem like a win for those advocating for stricter AI regulation. However, a closer look reveals a more nuanced picture.</p>
<p>The bill’s light-touch approach and narrow focus means that many in the AI industry, particularly the big AI labs, may be breathing a sigh of relief. Earlier in the week, Anthropic’s CEO Dario Amodei said of the bill, <em>“we believe its benefits likely outweigh its costs”</em> and <a href="https://x.com/elonmusk/status/1828205685386936567">Elon Musk tweeted</a> that <em>“California should probably pass the SB-1047 AI safety bill.”</em> - statements that suggest to me that they were happy with what was on the table.</p>
<p>On the other hand, those hoping for more comprehensive regulation may feel the bill does not go far enough. The focus on preventing catastrophic harms, while important, leaves many day-to-day AI ethics issues unaddressed.</p>
<p>The most significant impact is the bill’s potential to discourage the release of fully open, frontier-level models. While not explicitly prohibited, the bill’s provisions will make it challenging to release covered models openly. Whilst I don’t believe this in any way “kills open source AI”, as it only targets frontier models, this does potentially take us to a future where the most advanced AI capabilities are concentrated in the hands of a few large corporations.</p>
<p>In essence, SB-1047 strikes a delicate balance. And perhaps the legislators wouldn’t be doing their job if both sides of the debate weren’t at least a little bit unhappy.</p>]]></description><link>https://2point0.ai/posts/sb-1047-passes</link><guid isPermaLink="false">02641ef4-1b5e-5cb2-b831-65bb68064b9b</guid><pubDate>Fri, 30 Aug 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[AI's open source summer revolution]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/summer-revolution.D2hYGG2p_6tSsP.webp" srcset="https://2point0.ai/_astro/summer-revolution.D2hYGG2p_6tSsP.webp 1x,https://2point0.ai/_astro/summer-revolution.D2hYGG2p_6tSsP.webp 2x" alt="AI's open source summer revolution" /><figcaption>AI's open source summer revolution</figcaption></figure><p>It’s summertime and the living is easy. Unless, that is, you’re trying to keep up with events in the AI world. If you thought you could take a week’s holiday without missing some paradigm-shifting event, think again.</p>
<p>The last couple of weeks have seen a flurry of announcements and developments, forcing this one relaxed holidaymaker out of vacation mode and back into blogging mode. Let’s dive into it.</p>
<ul>
<li>Meta releases Llama 3.1, including a 405B parameter model rivalling proprietary heavy weights.</li>
<li>Mistral unveils two new models: the powerful Mistral Large 2 and the developer-friendly Mistral Nemo.</li>
<li>Ollama introduces native support for function calling, enhancing local LLM capabilities.</li>
</ul>
<p>For developers, builders and AI enthusiasts, there’s some juicy stuff in here. So let’s take a deeper dive into what’s new.</p>
<h2 id="meta-launches-llama-31-models">Meta launches Llama 3.1 models</h2>
<p>The big news came from Meta, who have <a href="https://ai.meta.com/blog/meta-llama-3-1">released new versions of Llama 3</a>, with increased context size (128k), better multilingual abilities and tool calling.</p>
<p><img src="https://2point0.ai/images/2024/meet-llama-3-1.webp" alt="Meet Llama 3.1"></p>
<p>This includes the release of a new 405B parameter model that offers “frontier level” capabilities - performance that was previously only available in the most advanced proprietary models like GPT-4o and Sonnet 3.5.</p>
<p>When I started this blog - only seven months ago - GPT-4 was a country mile ahead of everyone else. Now, not only have other proprietary models caught up (and overtaken), for the first time <a href="https://x.com/karpathy/status/1815842603377779140">frontier level LLM capabilities are available to everyone</a> to work with and build on.</p>
<p>This really is a huge moment. Mark Zuckerberg writes about <a href="https://about.fb.com/news/2024/07/open-source-ai-is-the-path-forward">the philosophy and arguments in favour of open source AI</a>, and there’s a fair amount of strategy at play here too. All eyes now turn to OpenAI to see if they have any GPT-5 shaped tricks up their sleeve, or if their moat truly has evaporated.</p>
<p>Of course, unless you have a small GPU cluster in your garage, you or I won’t be able to run the 405B model at home. Luckily, Llama 3.1 also comes in 8B and 70B parameter sized versions for us to prompt, RAG, fine-tune, optimise and just generally have fun with.</p>
<p>If you want to try the 405B model, the easiest place is probably to hop on to <a href="https://huggingface.co/chat">Hugging Chat</a> (unless you’re an EU citizen, in which case, VPN is your friend). The smaller 8B and 70B models are widely available on popular chat platforms, or can be downloaded from <a href="https://huggingface.co/meta-llama">Hugging Face</a> or <a href="https://ollama.com/library/llama3.1">Ollama</a>.</p>
<h2 id="mistral-launches-two-new-models">Mistral launches two new models</h2>
<p>In a case of exceptionally poor timing, whilst everyone was talking about the Llama 3.1 news, Mistral have also launched two new models that risk being overlooked, but definitely shouldn’t be.</p>
<p><a href="https://mistral.ai/news/mistral-large-2407">Mistral Large 2</a> is a 123B parameter model, with 128k context size, significantly improved capabilities and impressive benchmarks all-round. Following on from Mistral’s work on Codestral, they claim Mistral Large 2 compares favourably to Llama 3.1 405B in Maths and Coding.</p>
<p><img src="https://2point0.ai/images/2024/mistral-large-2-performance.webp" alt="Mistral Large 2 performance"></p>
<p>More exciting to me than the large model, is its little sibling <a href="https://mistral.ai/news/mistral-nemo/">Mistral Nemo</a>, a new 12B parameter model with 128k context size, built in collaboration with NVIDIA with an entirely permissive licence, and looks to be an absolute banger for its size category. This is a drop-in replacement for Mistral 7B, and will be sure to keep the fine-tune community busy over the coming months.</p>
<h2 id="ollama-function-calling">Ollama function calling</h2>
<p>One thing Llama 3.1 and the new Mistral models have in common is significantly improved support for tool use and function calling, built in to the model’s training. Which is all very convenient because my favourite tool for running LLMs locally, <a href="https://ollama.com/blog/tool-support">Ollama, has shipped version 0.3</a> with first-class support for tool use / function calling.</p>
<p><img src="https://2point0.ai/images/2024/ollama-tool-calling.webp" alt="Ollama tool calling"></p>
<p>Until now, it’s been <em>kind of</em> possible to implement function calling with Ollama, but the models weren’t really explicitly trained for it and the implementation involved too much double-sided sticky tape for my liking.</p>
<p>This release makes tool use a first-class feature of Ollama, supported in both its own chat API and the OpenAI-compatible endpoint. Combined with new models that are explicitly trained to handle tool use, all of a sudden the prospect of plugging local models into agentic systems is no longer a pipe dream.</p>
<h2 id="time-to-build">Time to build</h2>
<p>If you’re a developer, and you’re building with large language models, what a couple of weeks! The big picture is that for the first time, state of the art, frontier LLM capabilities are available to everyone to use and build on. But it’s not just a case of the bigger models getting bigger and better, the smaller models are improving too. Models that anyone can run on their local computer are as capable today as the leading proprietary models were a year ago.</p>
<p>With the capabilities of models improving across all size categories, and the tooling and dev infrastructure improving all the time, doors to opportunities open up that just weren’t possible a few months ago.</p>
<p>It’s a great time to be building in this space. I had to jump out of holiday mode to tell you this, but now I need to get coding. There’s stuff to build!</p>]]></description><link>https://2point0.ai/posts/ai-open-source-summer-revolution</link><guid isPermaLink="false">72416bb9-d63a-5756-a745-98aa58134b39</guid><pubDate>Mon, 29 Jul 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Claude 3.5 Sonnet takes the AI crown (for now)]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/claude-the-king.dB32nzCz_Ze8FPe.webp" srcset="https://2point0.ai/_astro/claude-the-king.dB32nzCz_Ze8FPe.webp 1x,https://2point0.ai/_astro/claude-the-king.dB32nzCz_Ze8FPe.webp 2x" alt="Is Claude 3.5 Sonnet the new King?" /><figcaption>Is Claude 3.5 Sonnet the new King?</figcaption></figure><p>Last week, <a href="https://www.anthropic.com/news/claude-3-5-sonnet">Anthropic announced Claude 3.5 Sonnet</a>, the latest update to their Claude family of models. As is usual with each new state-of-the-art LLM release, the new Sonnet raises the bar across a range of industry evaluations. And, in an unusual shocker for AI announcements, they even released the model for us to play with on the same day!</p>
<p>The AI community on Twitter / X have very quickly reached seeming consensus that the new Sonnet is indeed very good. Perhaps even, a GPT-4 killer?</p>
<p>So, how good is it? Has GPT-4 been dethroned? Let’s take a look.</p>
<h2 id="understanding-claude-35-sonnet">Understanding Claude 3.5 Sonnet</h2>
<p>It doesn’t seem that long ago that Anthropic were announcing Claude 3. In fact, it was literally only three months ago, but this is AI and space-time works a little differently here.</p>
<p>Claude 3 was delivered in three variants, positioned to give users a choice with clear trade-offs. Haiku, the smallest model, prioritised speed and cost. Sonnet, an all-rounder, the medium model that is best for most things. And Opus, the premium model, more intelligent and capable, but slower and more expensive.</p>
<p>Claude 3.5 Sonnet is the first of the three variants to be upgraded. Anthropic’s own benchmarks show it out-performing Claude 3 Opus, their previously best model, on all measures. It also outcompetes OpenAI’s GPT-4o model on all but two benchmarks.</p>
<p><img src="https://2point0.ai/images/2024/sonnet-evals.webp" alt="Claude 3.5 Sonnet benchmarks"></p>
<p>The fact that the new Sonnet now outperforms the old Opus is interesting as that negates the role of the slower and more expensive Opus. An even more impressive Opus must surely be around the corner, which is a tantalising prospect.</p>
<p>Notably, Sonnet can be used free of charge (with usage limits) through <a href="https://claude.ai">claude.ai</a> - Anthropic’s own consumer facing chat UI. There’s an interesting battle playing out here. OpenAI recently made GPT-4o their standard, free-to-use model, which is also a very good, free model. But Claude 3.5 Sonnet seems to have the edge, and makes <a href="https://claude.ai">claude.ai</a> a very compelling choice for new users wanting to experiment with adopting LLMs as part of their daily lives.</p>
<h2 id="artifacts">Artifacts</h2>
<p>In addition to the new model, <a href="https://claude.ai">claude.ai</a> receives a new feature called “Artifacts”. Any documents that Claude generates, such as text documents or code files, are displayed in a dedicated column next to the chat, and code is previewed in a sandbox-like environment.</p>
<p>It’s conceptually simple but a great UX. It creates a more seamless and natural flow when iterating on code files step by step. If you want your imagination piqued, <a href="https://x.com/minchoi/status/1805261552804602151">take a look at these examples</a> of folks putting the new Sonnet and Artifacts through its paces.</p>
<p><a href="https://x.com/dr_cintas/status/1804884790870462923"><img src="https://2point0.ai/images/2024/sonnet-tweet-1.webp" alt="Sonnet memory card game"></a>
<a href="https://x.com/alexalbert__/status/1804258091808231462"><img src="https://2point0.ai/images/2024/sonnet-tweet-2.webp" alt="SpaceX Starship lander game"></a></p>
<p>There are some response token size limits that larger artifacts may bump in to, but overall Artifacts is an important step for <a href="https://claude.ai">claude.ai</a> - it marks its evolution from a conversational chatbot to a collaborative work environment - a tool to help you write documents and code, all wrapped in a streamlined UX.</p>
<p>With these improvements, Claude is positioning itself as a formidable competitor to ChatGPT. In fact, could “competitor” be underplaying it?</p>
<h2 id="is-the-king-dead">Is the King dead?</h2>
<p>Claude’s update follows hot in the heels of the release of <a href="https://openai.com/index/hello-gpt-4o/">GPT-4o, OpenAI’s latest flagship model</a>. GPT-4o is faster and cheaper than GPT-4 Turbo, with much improved multi-modal vision and audio capabilities, and replaces the now ancient (in AI terms) GPT-3.5 as ChatGPT’s default free-to-use model.</p>
<p>Whilst GPT-4o undoubtedly raises the bar in terms of its multi-modal capabilities (the <a href="https://openai.com/index/hello-gpt-4o/">announcement post</a> features some great demo videos), for various - erm <a href="https://www.theverge.com/2024/5/20/24161253/scarlett-johansson-openai-altman-legal-action"><em>“reasons”</em></a> - many of the voice and multi-modal features are not yet in the public’s hands. In my admittedly subjective evaluations of GPT-4o, I find it falls short of GPT-4 Turbo for the kind of tasks that I typically use it for.</p>
<p>This leaves me confused about the GPT family of models right now. Everyone was expecting GPT-5, but we got GPT-4o. It’s billed as their flagship model, but is clearly inferior to GPT-4 Turbo for some types of tasks. OpenAI has hinted that GPT-4o is the first in a family of new models. But if so, where is the rest of the family? And when will we be able to talk with that flirty Scarlett Johansson sound-alike?</p>
<p>For now, I think it’s fair to say the crown has fallen.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Instead, the crown currently and deservedly belongs to Anthropic. I like the options their line of models give me, and I’m excited for new Haiku and Opus models. I love that their free-to-use model is currently the best model on the market. And I love Artifacts and the direction <a href="https://claude.ai">claude.ai</a> is heading. The boys and girls working at Anthropic are on a roll, and I’m a fan.</p>
<p>But only a fool would be writing OpenAI off. The question is not whether they will be able to raise the bar again, of course they will, but by how much so? Will it be to such an extent that they cement their position as market leaders for the next 12–18 months, as happened with GPT-4, or are we set for a closer run thing, with smaller and more incremental upgrades, with the gap between all the top LLM models narrowing?</p>
<p>There is one clear winner in all of this - us! The rising tide lifts everyone, and all users get to benefit from the increased choice and flexibility this competition brings.</p>
<p>But what excites me the most is that Sonnet is not some new bigger and more expensive model, it’s Claude’s medium-sized model, and remains the same cost. With improvements coming across the family of models, we will find that tomorrow’s smaller models will be as cpable as today’s larger models. If that trend continues, this brings prices (and energy demands) down, and opens access to advanced AI to many more potential users.</p>]]></description><link>https://2point0.ai/posts/claude-sonnet-takes-ai-crown</link><guid isPermaLink="false">1f7b1f19-63fa-580c-acc6-2daafd976ee3</guid><pubDate>Wed, 26 Jun 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Unpacking Apple's AI Strategy at WWDC 2024]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/apple-intelligence-wwdc-2024.c4Aw1v4i_1MtskE.webp" srcset="https://2point0.ai/_astro/apple-intelligence-wwdc-2024.c4Aw1v4i_1MtskE.webp 1x,https://2point0.ai/_astro/apple-intelligence-wwdc-2024.c4Aw1v4i_1MtskE.webp 2x" alt="Apple Intelligence at WWDC 2024" /><figcaption>Apple Intelligence at WWDC 2024</figcaption></figure><p>Apple’s <a href="https://developer.apple.com/wwdc24/">Worldwide Developer Conference 2024</a> (WWDC) kicked off this week, where, as expected, The Cupertino tech giant finally revealed their hand and demonstrated how AI will be coming to their devices and operating systems later this year.</p>
<p>With Microsoft and Google racing to out-AI each other, Apple have appeared to be behind the curve. Apple are rarely first to a category, but when they enter, it’s always time to pay attention. Their approach could shape how a billion consumers worldwide perceive and interact with artificial intelligence in their daily lives.</p>
<p><lite-youtube videoid="RXeOiIDNNek" videotitle="WWDC 2024 — June 10 | Apple"></lite-youtube></p>
<p>In this article, we’ll run through the key announcements from WWDC 2024, analyse Apple’s AI strategy, and explore the implications of their efforts to make AI more accessible and user-friendly.</p>
<h2 id="is-apple-behind-the-curve">Is Apple behind the curve?</h2>
<p>Apple is perceived to be behind the curve when it comes to AI. Certainly, they are late to embrace LLMs. But, that isn’t the full picture.</p>
<p>The first Apple devices to feature a ‘neural engine’ - a dedicated hardware component specifically designed to handle machine learning tasks efficiently - was <a href="https://www.wired.com/story/apples-neural-engine-infuses-the-iphone-with-ai-smarts/">back in 2017</a> with the launch of the iPhone X and the A11 Bionic chip. This predates ChatGPT’s launch, and the consumer buzz and hype surrounding AI by a good five years.</p>
<p>More recently, Apple has switched their entire Mac line-up over to Apple Silicon. All M series processors feature a powerful neural engine, multiple GPUs and unified memory, resulting in a surprisingly capable processor for ML and AI tasks.</p>
<p>Apple are only late to the party if you view this moment as their entrance. But, they’ve been stocking the bar and getting the playlist ready for some time!</p>
<h2 id="apple-intelligence">Apple Intelligence</h2>
<p>Contrasting with the Google IO event last month, where Google proudly used AI to count that they had <a href="https://techcrunch.com/2024/05/14/google-mentioned-ai-120-times-during-its-i-o-keynote/">mentioned “AI” over 120 times</a> during their keynote, I think I heard the term only once during the Apple keynote. Instead, Apple gave us a clever rebranding of AI as “Apple Intelligence”.</p>
<p><img src="https://2point0.ai/images/2024/apple-intelligence.webp" alt="Apple Intelligence"></p>
<p>This is a classic Apple move. It allows them to claim ownership of a category which until now they have been conspicuously absent.</p>
<p>Arguably, it’s also a canny move. Whilst AI is making waves, with that comes some murky waters. By reframing the category, Apple can attempt to keep their trunks clean. Apple will be content to let Google rush head first into the AI deep end as long as it’s scoring those <a href="https://www.theverge.com/2024/5/23/24162896/google-ai-overview-hallucinations-glue-in-pizza">glue-on-pizza own goals</a>, whilst Apple can dip its toes in and claim to be doing things differently.</p>
<h2 id="new-features-of-apple-intelligence">New features of Apple Intelligence</h2>
<p>Apple’s neural engine has been enabling subtle quality of life ML (Machine Learning) features such as predictive text or the various image recognition features in the Photos app for a while. Apple has never explicitly labelled these kinds of features as AI, but that is exactly what they are.</p>
<p>With Apple Intelligence, and the new OSes it will arrive with, Apple is significantly ramping up these kinds of ML-powered quality of life features all around the system - features that are designed to surface where you need them and when you need them.</p>
<p>Apple Intelligence brings plenty of new features - more than I can list - but here are a few that stand out:</p>
<ul>
<li>Writing tools - summarisation, proofreading, rewording, etc</li>
<li>Image playground - generative image tools</li>
<li>Genmoji - for those times when none of the standard 3,500 emoji icons perfectly express the required emotion</li>
<li>Priority notifications, priority messages in Mail, email summaries and smart replies</li>
<li>Photos - clean up tool, generate smart memories and collections, much improved semantic search</li>
<li>Math Notes - genuinely impressive dynamically calculated results for mathematical formula and equations</li>
<li>Smart script - use AI to smooth out your messy handwriting</li>
</ul>
<p><img src="https://2point0.ai/images/2024/apple-math-notes.webp" alt="Apple Math Notes"></p>
<h2 id="siris-ai-powered-upgrade">Siri’s AI-powered upgrade</h2>
<p>Siri, Apple’s much maligned digital assistant, is set for a long overdue and much needed kick up the virtual backside with some new LLM-powered abilities. Expect more natural exchanges of conversation, and deeper, more impressive abilities to instruct Siri to perform actions across different apps and systems. Siri is contextually aware of all our data - our contacts, calendar, photos and files - so there is a lot of potential for Siri to finally live up to the promise that it never quite delivered on.</p>
<p>And for those times when Siri isn’t able to help with your request, it has a buddy as backup. Where appropriate, Siri will ask you if you’d like your request to be handled by ChatGPT. You always explicitly <strong>opt in</strong> to this, and if you do GPT-4o will respond instead of Siri. This is free and available to all users without requiring an OpenAI account.</p>
<h2 id="whats-the-catch">What’s the catch?</h2>
<p><img src="https://2point0.ai/images/2024/apple-intelligence-compatibility.webp" alt="Apple Intelligence Compatibility"></p>
<p>The big caveat that all of these Apple Intelligence features carry is that you will need a relatively new device to take advantage of them. When Apple Intelligence is released in the Autumn, it will only be available on the iPhone 15 Pro and above, or any Mac or iPad with an M-series processor.</p>
<h2 id="the-privacy-tightrope">The privacy tightrope</h2>
<p>Apple’s reputation for user privacy is good and well deserved. They have stood out amongst the tech giants in defending users’ privacy and advocating for storing and processing data on device rather than in the cloud (and they take every opportunity to remind us when Google and Microsoft do the opposite).</p>
<p>For this reason, Apple finds itself in a tight spot. While small local ML models can impress for certain use cases, there will always remain a category of AI tasks that necessitate very large models hosted in data centres. Thus, if Apple is to compete, it must offload certain tasks to the cloud, and potentially undermine its good privacy reputation.</p>
<p>During the keynote, Apple emphasised privacy a lot. This is the approach they are taking:</p>
<ul>
<li>All user data is stored and processed locally, on device.</li>
<li>The majority of AI workloads will also be handled on device using a <a href="https://machinelearning.apple.com/research/introducing-apple-foundation-models">3B parameter LLM</a>.</li>
<li>Where necessary, Apple will offload more demanding AI workloads to what it calls “Private Cloud Compute” - Apple owned and controlled infrastructure where requests are encrypted and data never stored. Security researcher Mathew Green <a href="https://x.com/matthew_d_green/status/1800291897245835616">posted some good thoughts on this</a>.</li>
<li>Finally, for specific types of requests Apple will let users opt in to it being forwarded to OpenAI and GPT-4o. The agreement with OpenAI stipulates that they cannot to identify you through your requests or store your data, if you hold any weight in that. But the crucial thing is that you ultimately have the choice, on a per-request basis, whether or not the request goes out to OpenAI.</li>
</ul>
<p>It’s reassuring that Apple emphasises privacy, but this is tricky ground for any tech company to navigate. Microsoft recently dug itself into a hole with it’s <a href="https://thehackernews.com/2024/06/microsoft-revamps-controversial-ai.html">AI-powered Recall feature</a>, demonstrating that sceptical consumers have <a href="https://www.theguardian.com/world/interactive/2013/nov/01/snowden-nsa-files-surveillance-revelations-decoded#section/1">not forgotten Snowden</a>.</p>
<h2 id="conclusion">Conclusion</h2>
<p>This feels like a solid, yet safe entrance to the AI battleground by Apple. Except for Math Notes (which was pleasingly delightful) and the promise of a more powerful and capable Siri, most of the quality of life AI features Apple is introducing fall into the “seen it before” category.</p>
<p>But what we <strong>can</strong> expect, in the way that Apple is uniquely adept at doing, is the tightest and neatest integrations, so these intelligence features surface exactly where and when a user needs them, in a way that, if you’ll excuse the cliché, <em>“just works”</em>.</p>
<p>Notably missing was any multi-modal vision and voice features, like Google demoed with <a href="https://www.youtube.com/watch?v=nXVvvRhiGjI">Project Astra</a>, and OpenAI is rolling out with <a href="https://openai.com/index/hello-gpt-4o/">GPT-4o</a>. I suspect Apple are happy to err on the side of caution and deliver simple polished AI features, and let Google be the one telling its users to <a href="https://www.bbc.co.uk/news/articles/cd11gzejgz4o">eat rocks</a>!</p>
<p>Perhaps the most significant aspect of Apple Intelligence is its potential to bring AI capabilities to over a billion users around the world. Not just the tech nerds and AI enthusiasts, but everyday consumers. From grandparents to students, from professionals to hobbyists, Apple’s user base is as diverse as it is massive.</p>
<p>As Apple has done with past revolutionary technologies like the graphical user interface and multitouch screens, they now have the opportunity to make AI a ubiquitous part of our daily lives. If executed well, Apple Intelligence opens the doors to AI for billions of people, leading to truly global public understanding and acceptance of this technology.</p>]]></description><link>https://2point0.ai/posts/unpacking-apples-ai-strategy-wwdc-2024</link><guid isPermaLink="false">7641a39c-8c43-5f8d-83db-11a517daf6eb</guid><pubDate>Wed, 12 Jun 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Setup a local, private AI coding assistant with Continue and Ollama]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/continue-ollama.BDMp3U3u_Z1I6ty7.webp" srcset="https://2point0.ai/_astro/continue-ollama.BDMp3U3u_Z1I6ty7.webp 1x,https://2point0.ai/_astro/continue-ollama.BDMp3U3u_Z1I6ty7.webp 2x" alt="Setting up Continue with Ollama" /><figcaption>Setting up Continue with Ollama</figcaption></figure><p>In our previous post, I walked you through the process of <a href="https://2point0.ai/posts/continue-groq-llama3-superpowers">setting up Continue.dev with Groq and Llama 3</a>, resulting in a best-in-class, fast and powerful (GPT-4 comparable) AI coding assistant in your VS Code environment.</p>
<p>But what if you’re looking for a solution that prioritises privacy, allows for offline use, and keeps everything running locally on your own machine. Enter our old friend Ollama.</p>
<p>Ollama is an open source toolset for running large language models, and makes the process of downloading the running open weight models pleasingly simple. And of course, it integrates very easily with Continue, providing you with all the same powerful features without relying on external APIs and LLM providers.</p>
<p>What’s more, Ollama actually unlocks a couple of Continue feature’s that the Groq and Llama3 combo didn’t - namely tab auto-completions and custom embedding models (which powers Continue’s <a href="https://2point0.ai/posts/what-is-rag">RAG-like</a> code search features).</p>
<p>We’re going to dive into all of that and more in the article. So, whether you’re concerned about privacy, need to work offline, or simply prefer the flexibility and control of a local setup, this guide will walk you through all the steps to get up and running with Continue and Ollama. Let’s get started!</p>
<h2 id="setting-up-ollama">Setting up Ollama</h2>
<p>If you haven’t already done so, head over to <a href="https://ollama.com">ollama.com</a>, click the big download button and follow the instructions. If you need to, read my post on <a href="https://2point0.ai/posts/running-llms-with-ollama">running models locally with Ollama</a>, which walks you through the installation and basic mechanics of Ollama.</p>
<p>To use Ollama with Continue, we’re going to need three different models to experiment with different features of Continue.</p>
<ul>
<li>For the main coding assistant chat features, we’ll use Llama 3, just like we did in the last post. But whilst Groq gives us access to the full 70b parameter version of Llama 3, unless you’ve got some beefy GPUs at your disposal, we’re going to have to settle for the smaller 8b parameter version.</li>
<li>To benefit from tab autocompletion, we need a model that is specifically trained to handle what are known as Fill-the-Middle (FIM) predictions. Unlike normal text predictions which are adding tokens to the end of a sequence, with FIM you already have the beginning and the end and the model predicts what goes in the middle. Llama 3 does not support FIM, so instead well use StarCoder2 3b, a tiny model that should run pretty fast, and is trained specifically for coding tasks using different programming languages.</li>
<li>We’ll also download an embeddings model. We’ll configure Continue to use <code>nomic-embed-text</code> via Ollama to generate embeddings, and we’ll have a play with Continue’s code retrieval features.</li>
</ul>
<p>To install the models we need, open up your terminal and paste in the following lines:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="shell"><code><span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> pull</span><span style="color:#A3BE8C"> llama3:8b</span><span style="color:#616E88">           # 4.7 GB download</span></span>
<span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> pull</span><span style="color:#A3BE8C"> starcoder2:3b</span><span style="color:#616E88">       # 1.7 GB download</span></span>
<span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> pull</span><span style="color:#A3BE8C"> nomic-embed-text</span><span style="color:#616E88">    # 274 MB download</span></span></code></pre>
<p>In total, this is going to download about 6.7 GB of model weights. A great opportunity to step away from the computer and make a cup of tea ☕.</p>
<h2 id="integrating-ollama-with-continue">Integrating Ollama with Continue</h2>
<p>Once the models are downloaded, hop into VS Code and edit Continue’s <code>config.json</code> (hit <code>⇧+⌘+P</code> and type <code>continue config</code> to quickly find it).</p>
<p>All we need to do is make the following three changes:</p>
<ul>
<li><code>"models"</code> - add a definition for our local Llama 3 model so it is available to use in Continue.</li>
<li><code>"tabAutocompleteModel"</code> - set the tab autocomplete model to Starcoder 2.</li>
<li><code>"embeddingsProvider"</code> - set the embedding provider to Nomic Embed Text.</li>
</ul>
<p>See below:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="json"><code><span class="line"><span style="color:#ECEFF4">{</span></span>
<span class="line"><span style="color:#ECEFF4">  "</span><span style="color:#8FBCBB">models</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [</span></span>
<span class="line"><span style="color:#ECEFF4">    {</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">title</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">Local Llama 3 8b</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">provider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">ollama</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">model</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">llama3:8b</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">completionOptions</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span></span>
<span class="line"><span style="color:#ECEFF4">        "</span><span style="color:#8FBCBB">stop</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">&#x3C;|eot_id|></span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">]</span></span>
<span class="line"><span style="color:#ECEFF4">      },</span></span>
<span class="line"><span style="color:#D8DEE9">    ...</span></span>
<span class="line"><span style="color:#ECEFF4">    }</span></span>
<span class="line"><span style="color:#ECEFF4">  ],</span></span>
<span class="line"><span style="color:#ECEFF4">  "</span><span style="color:#8FBCBB">tabAutocompleteModel</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">title</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">Starcoder 2 3b</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">provider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">ollama</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">model</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">starcoder2:3b</span><span style="color:#ECEFF4">"</span></span>
<span class="line"><span style="color:#ECEFF4">  },</span></span>
<span class="line"><span style="color:#ECEFF4">  "</span><span style="color:#8FBCBB">embeddingsProvider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">title</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">Nomic Embed Text</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">provider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">ollama</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">model</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">nomic-embed-text</span><span style="color:#ECEFF4">"</span></span>
<span class="line"><span style="color:#ECEFF4">  },</span></span>
<span class="line"><span style="color:#D8DEE9">  ...</span></span>
<span class="line"><span style="color:#ECEFF4">}</span></span></code></pre>
<p>That’s all there is to it. Continue is now ready and waiting to assist your coding, locally powered by Ollama.</p>
<h2 id="using-continue-with-ollama">Using Continue with Ollama</h2>
<p>Now that everything is ready, we can try this out. Highlight some code, tap <code>⌘+L</code> to bring up the side panel, and make sure the “Local Llama 3 8b” model is selected in the drop box at the bottom of the chat panel. You can chat with Llama 3, ask questions about your code, and use all the slash commands we covered in the previous post. Similarly, highlight some code, tap <code>⌘+I</code> and instruct Llama to make changes to your code.</p>
<p>We covered all of this last time round, so if you need to get up to speed with the fundamentals of how to use Continue, read the post on <a href="https://2point0.ai/posts/continue-groq-llama3-superpowers">using Continue of Groq and Llama 3</a>.</p>
<p><img src="https://2point0.ai/images/2024/continue-chat.webp" alt="Continue chat side panel"></p>
<p>Using Ollama with Continue gives us some new toys to play with, so let’s try them out.</p>
<h3 id="tab-autocompletion">Tab autocompletion</h3>
<p>Tab autocomplete works like this: you are busy typing away writing some code; you momentarily pause typing to scratch your head; Continue takes the snippet of code you are working on, passes it to a Fill-the-Middle supporting LLM, and in the time it takes you to finish scratching and move your fingers back to the keyboard, it has had a go at completing the line or chunk of code that you’re working on; you can either ignore it, or if it’s a good prediction hit <code>TAB ⇥</code> to accept the changes.</p>
<p><video autoplay muted loop src="https://2point0.ai/video/2024/continue-autocomplete.mp4"></video></p>
<p>The promise is that Continue becomes this Jedi-like coding assistant that knows what you’re coding before you’ve even coded it. In practise though, your mileage may vary. I often switch AI tab autocomplete off - I find the UX slightly awkward as it works in tandem with native VS Code tab completions (which I use a lot), and I feel like the AI completions get in my way more than help me.</p>
<p>The Continue docs state they <em>“will be greatly improving the experience over the next few releases”</em>, suggesting the devs know it’s a bit half-baked currently. But it’s definitely worth trying out yourself - hopefully it will improve over time with future releases.</p>
<h3 id="embeddings-and-code-search">Embeddings and code search</h3>
<p>I wrote a little bit about embeddings in <a href="https://2point0.ai/posts/what-is-rag">my RAG explainer</a>. In short, an embedding is <a href="https://spiess.dev/note/engineering/ml/embeddings">a vector of numerical values that captures the semantic meaning of a chunk of text</a> (or in this case, a chunk of code). Embeddings are an important part of how large language models work, but for our understanding here it’s just important to know that we can use embeddings to compare how semantically close different chunks of text/code are.</p>
<p>Continue generates embeddings out of the box using Transformers.js - a decent “it just works” solution that generates embeddings of size 384. <code>nomic-embed-text</code> via Ollama will generate embeddings of size 786, which in theory should improve the accuracy of Continue’s code retrieval features.</p>
<p>The <a href="https://docs.continue.dev/walkthroughs/codebase-embeddings">Continue docs give some examples</a> where you might use code retrieval. It’s achieved using the <code>@codebase</code> or <code>@folder</code> context providers and typing a prompt. For example:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="text"><code><span class="line"><span>@codebase how do I implement the `LLMAdapter` abstract class?</span></span></code></pre>
<p>The above generates embeddings from your codebase, searches for a <code>LLMAdapter</code> abstract class, and attempts to explain how to implement a concrete version of the class.</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="text"><code><span class="line"><span>@src what events does the `Job` class emit</span></span></code></pre>
<p>This example generates embeddings from the <code>/src</code> folder, searches for a <code>Job</code> class and explains what events it emits.</p>
<p>This is powerful stuff - it turns your AI coding assistant from a coding expert with general knowledge, to a coding expert with specific knowledge about what you’re working on.</p>
<h2 id="conclusion">Conclusion</h2>
<p>By using Continue with Ollama, not only do you gain a fully local AI coding assistant, but you do so with complete control over your data and can ensure the privacy of your codebase. With Ollama’s support for tab autocompletion and custom embedding models, you can enhance Continue’s capabilities even further, making it an essential tool in your coding workflow.</p>
<p>But the real beauty of Continue lies in its flexibility. You don’t have to choose between the speed and power of Groq, or the privacy and offline capabilities of Ollama. Continue allows you to seamlessly switch between different models and setups, adapting to your specific needs and preferences. You can leverage the strengths of each approach, using Groq and Llama for lightning-fast coding assistance during your day-to-day work, and switching to Ollama when privacy is a top priority or when you need to work offline.</p>
<p>So, whether you’re a developer concerned about the confidentiality of your code, someone who frequently works in offline environments, or simply curious about the possibilities of local AI coding assistants, I encourage you to dive in and experiment with Continue and Ollama. The setup process is straightforward, and the potential benefits are immense. Have fun, and happy coding!</p>]]></description><link>https://2point0.ai/posts/local-coding-assistant-continue-ollama</link><guid isPermaLink="false">4f05ee8b-149f-59b6-935e-2ed3bcf424d6</guid><pubDate>Mon, 20 May 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[How using Continue, Groq and Llama 3 gives you coding superpowers]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/coding-superpowers.DabuKKty_23G2O.webp" srcset="https://2point0.ai/_astro/coding-superpowers.DabuKKty_23G2O.webp 1x,https://2point0.ai/_astro/coding-superpowers.DabuKKty_23G2O.webp 2x" alt="Coding superpowers with Continue, Groq and Llama 3" /><figcaption>Coding superpowers with Continue, Groq and Llama 3</figcaption></figure><p>When was the last time you searched Stack Overflow for a technical question? Yeah… thought so.</p>
<p>Of all the areas and industries AI is set to disrupt, software development and coding are where AI tools are the most polished and genuinely useful today. At our fingertips we have access to tools that understand the context of our code, can suggest improvements, write tests, explain concepts and just generally enhance our capabilities.</p>
<p>Amidst all the hype and commercial offerings, there’s a completely free setup that provides AI coding assistance of remarkable quality and blistering speed. I’m talking GPT-4 comparable language models, running on specialised hardware designed for ludicrous AI inference performance. For free.</p>
<p>Even if you’ve already got AI baked into your dev workflow, free is hard to argue with. So strap in and let me show you how to get world-class AI coding assistance in your IDE today.</p>
<h2 id="the-tools-well-be-using">The tools we’ll be using</h2>
<p>Within our IDE, we’ll install the <a href="https://www.continue.dev/">Continue extension</a> - an open source AI coding assistant that adds a range of AI-powered enhancements to your development environment. Continue can be configured to run with a wide selection of different LLM providers including both commercial and local models.</p>
<p>We’ll be using Continue with <a href="https://groq.com/">Groq</a>. Groq is a hardware company that has developed specialised chips called Language Processing Units (LPUs) designed specifically to run large language models extremely efficiently. Their LPUs overcome the compute and memory limitations of traditional hardware like GPUs, resulting in much faster inference speeds.</p>
<p>We can take advantage of Groq’s LPUs via their API. Because all of this technology is so new, access to their API is currently free of charge whilst they build out and test the technology. Usual caveats apply: don’t expect it be free for ever; expect some throttling and limitations. In my experience it has been working flawlessly so taking advantage of it for free feels like a no-brainer.</p>
<p>Groq supports a limited set of open models, but they do support the very capable <a href="https://llama.meta.com/llama3/">Llama 3 from Meta</a>, one of the latest open-source large language models optimised for coding tasks and on par with models like GPT-4 in this domain.</p>
<h2 id="setting-up-groq-and-continue">Setting up Groq and Continue</h2>
<h3 id="1-install-continue">1. Install Continue</h3>
<p>Continue is available as a free <a href="https://marketplace.visualstudio.com/items?itemName=Continue.continue">VS Code extenion</a>. To install it, open up the extensions panel (<code>⇧+⌘+X</code>), search for “Continue” and click on install.</p>
<p><img src="https://2point0.ai/images/2024/continue-extension.webp" alt="Continue extension"></p>
<h3 id="2-sign-up-for-groq">2. Sign up for Groq</h3>
<p>To use Groq’s API’s you’ll need to head over to <a href="https://console.groq.com">Groq Cloud</a>, and once you’ve registered up you’ll be able to create an API key.</p>
<p><img src="https://2point0.ai/images/2024/groq-cloud.webp" alt="Groq Cloud API keys"></p>
<h3 id="3-configure-continue">3. Configure Continue</h3>
<p>So far, so easy. Once Continue is installed you’ll see a new button in your activity bar on the far left. It’s recommended to click and drag that button over to the right of your workbench to create a secondary sidebar - this way you’ll be able to use Continue alongside whatever you’ve got in your primary sidebar.</p>
<p>The keyboard shortcut <code>⌥+⌘+L</code> toggles the Continue sidebar to and from view. At the bottom of the Continue sidebar, you should see a little gear icon which you can click to edit the extension’s <code>config.json</code> file.</p>
<p>Within the <code>"models"</code> array, you’ll find a number of preconfigured models. You can keep those or remove them, up to you, but add in the following two entries, entering your Groq API key where shown:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="json"><code><span class="line"><span style="color:#ECEFF4">{</span></span>
<span class="line"><span style="color:#ECEFF4">  "</span><span style="color:#8FBCBB">models</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [{</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">title</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">Groq Llama 8b</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">provider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">openai</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">model</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">llama3-8b-8192</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">apiBase</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">https://api.groq.com/openai/v1</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">apiKey</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">&#x3C;GROQ_API_KEY></span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">completionOptions</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">stop</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">&#x3C;|eot_id|></span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">]</span></span>
<span class="line"><span style="color:#ECEFF4">    }</span></span>
<span class="line"><span style="color:#ECEFF4">  },</span></span>
<span class="line"><span style="color:#ECEFF4">  {</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">title</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">Groq Llama 70b</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">provider</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">openai</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">model</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">llama3-70b-8192</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">apiBase</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">https://api.groq.com/openai/v1</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">apiKey</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">&#x3C;GROQ_API_KEY></span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#8FBCBB">completionOptions</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span></span>
<span class="line"><span style="color:#ECEFF4">      "</span><span style="color:#8FBCBB">stop</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">&#x3C;|eot_id|></span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">]</span></span>
<span class="line"><span style="color:#ECEFF4">    }</span></span>
<span class="line"><span style="color:#ECEFF4">  }]</span></span>
<span class="line"><span style="color:#ECEFF4">}</span></span></code></pre>
<p>And that’s it - you’re now setup and ready to use Continue. So, let’s have a look at what you can do with it.</p>
<h2 id="how-to-use-continue">How to use Continue</h2>
<p>Now that Continue is installed, configured and hooked up with Groq, let’s explore how you can use it in your development workflow.</p>
<h3 id="highlight-and-chat">Highlight and chat</h3>
<p>With the Continue side panel open, make sure you’ve selected Llama 3 70b from the dropdown at the bottom of the panel, and you can start chatting with the model just like you would in ChatGPT.</p>
<p>But if you first highlight some code and then press <code>⌘+L</code>, that code snippet will be added into the chat as context, providing a convenient shortcut to start asking about parts of your code.</p>
<p><img src="https://2point0.ai/images/2024/continue-chat.webp" alt="Continue chat side panel"></p>
<h3 id="context-providers">Context providers</h3>
<p>A context provider in Continue is a plugin that provides context from your workspace (or an external source) to the LLM. All you have to do is reference the context provider by typing <code>@ + name</code>, and under the hood Continue will find that extra context to provide to the LLM.</p>
<p>For example, the context providers <code>@codebase</code> and <code>@directory</code> work similarly by doing some <a href="https://2point0.ai/posts/what-is-rag">RAG magic</a> under the hood, creating embeddings from your source code, retrieving relevant bits of code, and providing those relevant chunks to the LLM as context to your conversation.</p>
<p>Alternatively, <code>@Git Diff</code> provides details of changes to the current working branch as context. This is great for reminding yourself what you’ve been working on for the past 8 hours.</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="text"><code><span class="line"><span>@Git Diff Please summarise what I've actually done in these 66 changed files 🙏🏻</span></span></code></pre>
<p>Context providers are pretty powerful and can plug in to your GitHub issues, Jira tickets or any local or remote data source. And as they are plugins, you can create your own. For more details, read up on <a href="https://docs.continue.dev/customization/context-providers#file-tree">Context Providers in the Continue docs</a>.</p>
<h3 id="slash-commands">Slash commands</h3>
<p>Slash commands are powerful shortcuts that are activated by typing <code>/ + command</code>. There are a few built-in commands. For example, you can select a piece of code, hit <code>⌘+L</code> to bring it up in the chat panel, then type: <code>/edit refactor using a more performant sort algorithm</code>. Then, at blazing speed thanks to Groq, Continue will bring up a diff editor with refactored changes for you to either accept or reject.</p>
<p>I commonly find myself using the <code>/commit</code> command to suggest useful and descriptive diff commit messages.</p>
<p>As with context providers, Continue has a few built in slash commands, but it is also possible to write your own custom commands. For more details, read the <a href="https://docs.continue.dev/customization/slash-commands#custom-slash-commands-1">Continue docs on Slash Commands</a>.</p>
<h3 id="inline-instructions">Inline instructions</h3>
<p>Similar to how the <code>/edit</code> command works, it’s also possible to give Continue instructions inline without using the separate chat panels and diff editors. Simply highlight the code you want to edit or refactor, hit <code>⌘+I</code> and type the instruction into the overlay text box that appears. Continue will edit the code in place, and you’ll have the opportunity to accept or reject all the code or individual lines.</p>
<p>Using this method it’s also possible to issue further instructions so you can iteratively work with Continue to tweak and tune changes to your liking.</p>
<p><img src="https://2point0.ai/images/2024/continue-editing.webp" alt="Inline instruction changes"></p>
<h2 id="wrapping-up">Wrapping up</h2>
<p>With Continue, we’ve got a fantastic example of how AI can turbocharge a developer’s capabilities. Combining Continue with Groq gives us blazing fast, top-tier language models integrated directly into your IDE - it’s like having a brilliant coding mentor, assistant and encyclopedia, sat next to you at your beck and call. Oh, and did I mention it’s free?</p>
<p>In an upcoming post, I’ll show you how to take things fully private and local by setting up Continue with Ollama. We’ll also dive into tab autocompletes and custom embeddings, two features not natively supported by Groq / Llama 3.</p>
<p>The AI coding revolution is well on it’s way. Developers who embrace these tools are giving themselves a game-changing productivity advantage. Don’t get left behind - subscribe to the <a href="https://www.typingmind.com/feed.xml">RSS feed</a> and follow me <a href="https://twitter.com/aaronrussell">@aaronrussell on X</a> to stay in the loop. Let me know what AI-powered dev tools you’re using that I should check out next!</p>]]></description><link>https://2point0.ai/posts/continue-groq-llama3-superpowers</link><guid isPermaLink="false">b951a167-e1c6-5025-98a3-2e1a53077e5b</guid><pubDate>Thu, 02 May 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Meet the News Shift]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/news-desk.DkoZ_BDk_Z75uAv.webp" srcset="https://2point0.ai/_astro/news-desk.DkoZ_BDk_Z75uAv.webp 1x,https://2point0.ai/_astro/news-desk.DkoZ_BDk_Z75uAv.webp 2x" alt="Meet the News Shift" /><figcaption>Meet the News Shift</figcaption></figure><p>In the rapidly moving world of AI, blink, and you’ll likely miss at least one (if not several) groundbreaking announcements bringing us one step closer to AGI. Heaven forbid you actually sleep at night.</p>
<p>Last week 2point0 published its <a href="https://2point0.ai/posts/ai-week-240412">first news piece</a> - our valiant effort to curate and summarise the week’s most noteworthy developments in AI. But doing so highlighted a problem: how can a single human being - even a dedicated enthusiast - possibly keep abreast of the latest AI news and trends, whilst simultaneously running their <em>real</em> business, feeding their family, walking their dog, etc.</p>
<p>The answer, of course, was to use the very technology we’re trying to understand. By assembling an expert team of AI analysts, copywriters and editors - in this case powered by <a href="https://www.anthropic.com/news/claude-3-family">Claude 3’s Haiku and Opus</a> models - I was able to turn something that might have taken me days to complete, to something that took minutes.</p>
<p>This experience sparked the inception of a new project, a framework for composing autonomous AI-powered workflows, that I call <a href="https://github.com/lebrunel/shifts">Shifts</a>.</p>
<h2 id="announcing-shifts">Announcing Shifts</h2>
<p>Shifts is an Elixir framework for composing autonomous agent workflows, using a mixture of LLM backends. Shift’s is heavily inspired by <a href="https://www.crewai.com/">CrewAI</a> - a Python AI agent framework. I wanted a similar tool to exist for Elixir devs, so I started building one.</p>
<p>A Shift is a module that implements a <code>work/2</code> function, defining a workflow for a given input. There are <code>Workers</code> who perform <code>Chores</code> (analogous to CrewAI’s Agent’s and Tasks), and optionally <code>Tool</code>’s can be used to complete the work.</p>
<p>Work can be described as simple linear workflows, or as complex systems with nested branches, looping and conditionals. For a simple example, here is the (slightly truncated) version of the 2point0 news shift:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="elixir"><code><span class="line"><span style="color:#81A1C1">defmodule</span><span style="color:#8FBCBB"> NewsShift</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#81A1C1">  use</span><span style="color:#8FBCBB"> Shifts</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">Shift</span></span>
<span class="line"></span>
<span class="line"><span style="color:#616E88">  # A Shift may have many workers</span></span>
<span class="line"><span style="color:#D8DEE9FF">  worker </span><span style="color:#ECEFF4;font-weight:bold">:</span><span style="color:#D8DEE9;font-weight:bold">analyst</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> role</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">News Analyst</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">    goal</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">Create concise summaries of the latest news and trends in the AI space.</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">    story</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">You are an experienced analyst in the AI space...</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">	llm</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span><span style="color:#8FBCBB">Shifts</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">LLM</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">Anthropic</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> model</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">claude-3-haiku-20240307</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D8DEE9FF">  worker </span><span style="color:#ECEFF4;font-weight:bold">:</span><span style="color:#D8DEE9;font-weight:bold">copywriter</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> role</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">Copywriter</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">    goal</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">Write engaging web content for blogs in the AI space.</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">    story</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">You are creative and exceptionally talented copywriter..</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">    llm</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> {</span><span style="color:#8FBCBB">Shifts</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">LLM</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">Anthropic</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> model</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">claude-3-sonnet-20240229</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#616E88">  # Implementing `work/2` defines the operation of the Shift</span></span>
<span class="line"><span style="color:#81A1C1;font-weight:bold">  @</span><span style="color:#D8DEE9;font-weight:bold">impl</span><span style="color:#81A1C1"> true</span></span>
<span class="line"><span style="color:#81A1C1">  def</span><span style="color:#88C0D0"> work</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9FF">shift</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> urls</span><span style="color:#ECEFF4">)</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#D8DEE9FF">    shift</span></span>
<span class="line"><span style="color:#81A1C1">    |></span><span style="color:#88C0D0"> each</span><span style="color:#ECEFF4">(</span><span style="color:#ECEFF4;font-weight:bold">:</span><span style="color:#D8DEE9;font-weight:bold">analyse</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> urls</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9"> &#x26;</span><span style="color:#D8DEE9FF">analyse_news</span><span style="color:#81A1C1">/</span><span style="color:#B48EAD">2</span><span style="color:#ECEFF4">)</span></span>
<span class="line"><span style="color:#81A1C1">    |></span><span style="color:#88C0D0"> task</span><span style="color:#ECEFF4">(</span><span style="color:#ECEFF4;font-weight:bold">:</span><span style="color:#D8DEE9;font-weight:bold">draft</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9"> &#x26;</span><span style="color:#D8DEE9FF">draft_article</span><span style="color:#81A1C1">/</span><span style="color:#B48EAD">1</span><span style="color:#ECEFF4">)</span></span>
<span class="line"><span style="color:#81A1C1">  end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#81A1C1">  defp</span><span style="color:#88C0D0"> analyse_news</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9FF">shift</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> url</span><span style="color:#ECEFF4">)</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#88C0D0">    task</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9FF">shift</span><span style="color:#ECEFF4">,</span><span style="color:#ECEFF4;font-weight:bold"> :</span><span style="color:#D8DEE9;font-weight:bold">summary</span><span style="color:#ECEFF4">,</span><span style="color:#ECEFF4"> [</span></span>
<span class="line"><span style="color:#D8DEE9FF">      task</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> """</span></span>
<span class="line"><span style="color:#A3BE8C">      Scrape the article at the given URL, analyse the content and create a summary document.</span></span>
<span class="line"><span style="color:#A3BE8C">      Your analysis should...</span></span>
<span class="line"><span style="color:#A3BE8C">      URL: </span><span style="color:#81A1C1">#{</span><span style="color:#A3BE8C">url</span><span style="color:#81A1C1">}</span></span>
<span class="line"><span style="color:#ECEFF4">      """</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">      output</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">A summary document comprised of the following structure...</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">      tools</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> [</span><span style="color:#8FBCBB">ScrapeArticleTool</span><span style="color:#ECEFF4">],</span></span>
<span class="line"><span style="color:#D8DEE9FF">      worker</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4;font-weight:bold"> :</span><span style="color:#D8DEE9;font-weight:bold">analyst</span></span>
<span class="line"><span style="color:#ECEFF4">    ])</span></span>
<span class="line"><span style="color:#81A1C1">  end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#81A1C1">  defp</span><span style="color:#88C0D0"> draft_article</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9FF">%</span><span style="color:#ECEFF4">{</span><span style="color:#D8DEE9FF">analyse</span><span style="color:#ECEFF4">:</span><span style="color:#D8DEE9FF"> summaries</span><span style="color:#ECEFF4">})</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#D8DEE9FF">    context </span><span style="color:#81A1C1">=</span></span>
<span class="line"><span style="color:#D8DEE9FF">      summaries</span></span>
<span class="line"><span style="color:#81A1C1">      |></span><span style="color:#8FBCBB"> Enum</span><span style="color:#ECEFF4">.</span><span style="color:#88C0D0">map</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9">&#x26;</span><span style="color:#8FBCBB">String</span><span style="color:#ECEFF4">.</span><span style="color:#88C0D0">trim</span><span style="color:#81A1C1">/</span><span style="color:#B48EAD">1</span><span style="color:#ECEFF4">)</span></span>
<span class="line"><span style="color:#81A1C1">      |></span><span style="color:#8FBCBB"> Enum</span><span style="color:#ECEFF4">.</span><span style="color:#88C0D0">join</span><span style="color:#ECEFF4">(</span><span style="color:#ECEFF4">"</span><span style="color:#EBCB8B">\n\n</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">)</span></span>
<span class="line"><span style="color:#D8DEE9FF">    </span></span>
<span class="line"><span style="color:#8FBCBB">    Chore</span><span style="color:#ECEFF4">.</span><span style="color:#88C0D0">new</span><span style="color:#ECEFF4">([</span></span>
<span class="line"><span style="color:#D8DEE9FF">      task</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> """</span></span>
<span class="line"><span style="color:#A3BE8C">      Using the given summaries, draft a news digest that covers all of the latest AI news.</span></span>
<span class="line"><span style="color:#A3BE8C">      You are writing for...</span></span>
<span class="line"><span style="color:#ECEFF4">      """</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">      output</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">A markdown formatted article. Maximum 1200 words in total.</span><span style="color:#ECEFF4">"</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">      context</span><span style="color:#ECEFF4">:</span><span style="color:#D8DEE9FF"> context</span><span style="color:#ECEFF4">,</span></span>
<span class="line"><span style="color:#D8DEE9FF">      worker</span><span style="color:#ECEFF4">:</span><span style="color:#ECEFF4;font-weight:bold"> :</span><span style="color:#D8DEE9;font-weight:bold">copywriter</span></span>
<span class="line"><span style="color:#ECEFF4">    ])</span></span>
<span class="line"><span style="color:#81A1C1">  end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#81A1C1">end</span></span></code></pre>
<p>And this is the <code>ScrapeArticleTool</code> that the analysts can use:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="elixir"><code><span class="line"><span style="color:#81A1C1">defmodule</span><span style="color:#8FBCBB"> ScrapeArticleTool</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#81A1C1">  use</span><span style="color:#8FBCBB"> Shifts</span><span style="color:#ECEFF4">.</span><span style="color:#8FBCBB">Tool</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D8DEE9FF">  description </span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">Scrapes a URL and returns a web page as readable plain text</span><span style="color:#ECEFF4">"</span></span>
<span class="line"><span style="color:#D8DEE9FF">  param </span><span style="color:#ECEFF4;font-weight:bold">:</span><span style="color:#D8DEE9;font-weight:bold">url</span><span style="color:#ECEFF4">,</span><span style="color:#ECEFF4;font-weight:bold"> :</span><span style="color:#D8DEE9;font-weight:bold">string</span><span style="color:#ECEFF4">,</span><span style="color:#ECEFF4"> "</span><span style="color:#A3BE8C">URL of the page to scrape</span><span style="color:#ECEFF4">"</span></span>
<span class="line"></span>
<span class="line"><span style="color:#81A1C1">  def</span><span style="color:#88C0D0"> call</span><span style="color:#ECEFF4">(</span><span style="color:#616E88">_shift</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> %</span><span style="color:#ECEFF4">{</span><span style="color:#ECEFF4">"</span><span style="color:#A3BE8C">url</span><span style="color:#ECEFF4">"</span><span style="color:#81A1C1"> =></span><span style="color:#D8DEE9FF"> url</span><span style="color:#ECEFF4">})</span><span style="color:#81A1C1"> do</span></span>
<span class="line"><span style="color:#D8DEE9FF">    %</span><span style="color:#ECEFF4">{</span><span style="color:#D8DEE9FF">title</span><span style="color:#ECEFF4">:</span><span style="color:#D8DEE9FF"> title</span><span style="color:#ECEFF4">,</span><span style="color:#D8DEE9FF"> article_text</span><span style="color:#ECEFF4">:</span><span style="color:#D8DEE9FF"> body</span><span style="color:#ECEFF4">}</span><span style="color:#81A1C1"> =</span><span style="color:#8FBCBB"> Readability</span><span style="color:#ECEFF4">.</span><span style="color:#88C0D0">summarize</span><span style="color:#ECEFF4">(</span><span style="color:#D8DEE9FF">url</span><span style="color:#ECEFF4">)</span></span>
<span class="line"><span style="color:#ECEFF4">    "</span><span style="color:#A3BE8C"># </span><span style="color:#81A1C1">#{</span><span style="color:#A3BE8C">title</span><span style="color:#81A1C1">}</span><span style="color:#EBCB8B">\n\n</span><span style="color:#81A1C1">#{</span><span style="color:#A3BE8C">body</span><span style="color:#81A1C1">}</span><span style="color:#ECEFF4">"</span></span>
<span class="line"><span style="color:#81A1C1">  end</span></span>
<span class="line"><span style="color:#D8DEE9FF">  </span></span>
<span class="line"><span style="color:#81A1C1">end</span></span></code></pre>
<p>I decided against using the names Agent or Task to avoid ambiguity with Elixir’s standard library modules of the same name. But I like the word “chore” - it implies a burden or drudgery - a necessary but often tedious task that we’d rather offload to someone or something else.</p>
<p>Imagine a world where AI handles the drudgery of data entry, report generation, and routine analysis, leaving you to channel your talents towards problem-solving, strategic thinking, and innovation. This is the promise of Shifts – <em>getting AI to handle the mundane so we can focus on things we care about</em>.</p>
<h2 id="mix-and-match-llms">Mix and match LLMs</h2>
<p>Shifts is designed to be LLM agnostic, and currently it has adapters for Anthropic’s Claude 3 models, and Hermes 2 Pro running on Ollama (OpenAI coming soon). Developer’s can mix and match LLMs, plugging different models into different parts of the same workflow.</p>
<p>For example, Claude’s Haiku offers great bang for you buck for simple intermediate tasks where you don’t necessarily care about the polish of the final output. Claude’s Opus can then be rolled out for a final “refinement” task to polish up and finish off the work.</p>
<p>When I’m building out a workflow and testing it, I can plug into Hermes 2 Pro through Ollama, saving paying for wasted API calls. And when I’m ready for the real deal, it’s a one-liner to swap to Claude, or soon ChatGPT.</p>
<h2 id="show-me-the-code">Show me the code!</h2>
<p>You can check out Shifts, and my other open source Elixir+AI work, over on GitHub:</p>
<ul>
<li><a href="https://github.com/lebrunel/shifts">Shifts</a> - Autonomous AI agent workflows</li>
<li><a href="https://github.com/lebrunel/anthropix">Anthropix</a> - Unofficial Anthropic API client</li>
<li><a href="https://github.com/lebrunel/ollama-ex">Ollama-ex</a> - Ollama API client and library</li>
</ul>
<p>I’m excited about the possibilities Shifts enables. But it is in <strong>very</strong> early development. For now, I’d caution against using it for anything other than kicking the tyres. I’m at that stage where I’m still figuring out the right design and approach for a few of the core mechanics, and breaking changes are certain. There’s lots to work on: metrics (token count), streaming, task delegation, while loops, conditionals, and much more besides.</p>
<p>But it’s already beginning to feel <em>right</em>. As I flesh out the code and add docs, the design will stabilise, and I’ll soon announce when Shifts is ready for more eyes and more users. Stay tuned!</p>]]></description><link>https://2point0.ai/posts/meet-the-news-shift</link><guid isPermaLink="false">c37855d6-feb5-5b4f-8f2b-4ee9cfeeffb8</guid><pubDate>Tue, 16 Apr 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[The AI week: AI music, local LLM browsers, and latest open model releases]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/ai-week-240412.w8aSB3_e_1PP8Eo.webp" srcset="https://2point0.ai/_astro/ai-week-240412.w8aSB3_e_1PP8Eo.webp 1x,https://2point0.ai/_astro/ai-week-240412.w8aSB3_e_1PP8Eo.webp 2x" alt="AI Week: 12 April 2024" /><figcaption>AI Week: 12 April 2024</figcaption></figure><p><em>When I started this blog I was drawn to the idea of creating a blog about AI, writen by a human. And every post to date has been written by a human - <a href="https://twitter.com/aaronrussell">by me</a>! But, my pace of publishing (currently less then one post/week) is unable to keep up with the speed of news and events in AI. So I’ve decied to do a little experiment:</em></p>
<p><em>I’ll keep writing how-to’s and techy tutorials, and throughout my week I’ll collect links to interesting and news-worthy stuff in and around AI. And then, I’ll get the robots to write the news.</em></p>
<p><em>This is the first such post, written - apart from this bit - entirely by AI. It’s experimental, and I’ll fine tune the process over the coming weeks. And when I’ve got it nailed, I’ll share exactly how I do it here on this blog.</em></p>
<hr>
<h2 id="udio-synthesizes-music-on-demand-via-ai">Udio synthesizes music on demand via AI</h2>
<figure>
  <a href="https://udio.com">
    <img src="/images/2024/udio-launch.webp" alt="Udio Music">
  </a>
  <figcaption>www.udio.com</figcaption>
</figure>
<p>A new AI music generator called <a href="https://udio.com/">Udio</a> launched this week allowing users to create high-fidelity musical tracks from text prompts. Like other AI music tools such as <a href="https://suno.ai">Suno</a>, Udio can generate music across a variety genres, from hip hop, to country, to classical and everything in between.</p>
<p>Udio uses a two-stage process, first employing a large language model to generate lyrics, then synthesizing the actual audio using a diffusion model. It has built-in filters to block recreations of copyrighted music. It’s an impressive feat, and is set to further heat up the debate around the impact of AI on the wider music and creative industries.</p>
<h2 id="opera-allowing-local-llm-use">Opera Allowing Local LLM Use</h2>
<figure>
  <img src="/images/2024/opera-llm.webp" alt="Udio Music">
</figure>
<p>In a significant development, <a href="https://techcrunch.com/2024/04/03/opera-will-now-allow-users-download-and-use-llms-locally/">Opera announced</a> it will enable users to download and run over 150 large language models (LLMs) locally in their browser.</p>
<p>This local LLM feature is part of Opera’s AI Feature Drops Program, leveraging the open source <a href="https://ollama.ai/">Ollama</a> framework to run the models. Running LLMs locally offers Opera’s users data privacy and security as well as the flexibility to find and use models specialised for specifc tasks.</p>
<h2 id="this-weeks-new-open-models">This week’s new open models</h2>
<p>A flurry of exiting new open models were announced this week, closing the gap between the proprietry big boys and the open source LLM scene.</p>
<h4 id="mistralais-mixtral-8x22b---a-powerful-open-model">MistralAI’s Mixtral 8x22B - A powerful open model</h4>
<p>Mixtral 8x22B is <a href="https://huggingface.co/mistral-community/Mixtral-8x22B-v0.1">MistralAI’s new release</a>, a state-of-the-art open source language model expected to outperform its previous Mixtral 8x7B offering and compete with Claude 3 and GPT-4. Mixtral 8x22B boasts a whopping 176 billion parameters and an impressive 65,000 token context window.</p>
<h4 id="stability-ai-releases-stable-lm-2-12b">Stability AI releases Stable LM 2 12B</h4>
<p><a href="https://stability.ai/news/introducing-stable-lm-2-12b">Stability AI unveiled</a> their new 12 billion parameter <a href="https://huggingface.co/stabilityai/stablelm-2-12b">Stable LM 2</a> model, available in base and instruction-tuned versions. Trained on seven languages including English and Spanish, it aims to provide efficient multilingual performance.</p>
<h4 id="coheres-command-r-enterprise-grade-open-llm">Cohere’s Command R+: Enterprise grade open LLM</h4>
<p><a href="https://txt.cohere.com/command-r-plus-microsoft-azure/">Command R+</a> is Cohere’s powerful new language model tailored for enterprise use cases. Building on their existing Command R offering, R+ adds advanced retrieval augmentation, multilingual support across 10 languages, and enhanced tool use for workflow automation.</p>
<h4 id="google-expands-gemma-with-codegemma-and-recurrentgemma">Google expands Gemma with CodeGemma and RecurrentGemma</h4>
<p>Google <a href="https://developers.googleblog.com/2024/04/gemma-family-expands.html">unveiled two additions</a> to its open Gemma model family: <a href="https://huggingface.co/google/codegemma-7b-it">CodeGemma</a> for code AI tasks and RecurrentGemma, an efficiency-optimized research model. CodeGemma aims to streamline development workflows via intelligent code completion, generation and chat capabilities.</p>
<p>Meanwhile, <a href="https://huggingface.co/google/recurrentgemma-2b-it">RecurrentGemma</a> leverages a new recurrent architecture and local attention mechanism to boost memory efficiency for high throughput research use cases.</p>
<h2 id="metas-llama-3-coming-soon-still">Meta’s Llama 3 coming soon… (still)</h2>
<figure>
  <img src="/images/2024/three-llamas.webp" alt="Waiting for Llama3...">
  <figcaption>Waiting for Llama 3...</figcaption>
</figure>
<p>Meta <a href="https://techcrunch.com/2024/04/09/meta-confirms-that-its-llama-3-open-source-llm-is-coming-in-the-next-month/">confirmed plans</a> to release its next-generation open source Llama 3 language model within the next month. Llama 3 will significantly upgrade Meta’s foundational AI for generative assistants.</p>
<p>Expected enhancements include around 140 billion parameters (up from 70B in Llama 2), better handling of complex topics, and overall improved response quality. Meta will roll out multiple Llama 3 versions this year but remains cautious on generative AI beyond text for now.</p>]]></description><link>https://2point0.ai/posts/ai-week-240412</link><guid isPermaLink="false">3e44b3b5-7c94-5c8f-81cd-d8709123d897</guid><pubDate>Fri, 12 Apr 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[What is RAG? Retrieval Augmented Generation explained]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/ragnifying-glass.DPoFRW3c_pTMKj.webp" srcset="https://2point0.ai/_astro/ragnifying-glass.DPoFRW3c_pTMKj.webp 1x,https://2point0.ai/_astro/ragnifying-glass.DPoFRW3c_pTMKj.webp 2x" alt="What is RAG?" /><figcaption>What is RAG?</figcaption></figure><p>When I started playing with LLMs and learning about the technology, I kept reading about “doing RAG” or building a “RAG app” and, honestly, for a long time I didn’t even understand what RAG was.</p>
<p>RAG - or Retrieval Augmented Generation - is a technique that allows large language models (LLMs) to process and generate responses from very long, extensive context by intelligently retrieving and providing only the most relevant information to the model.</p>
<p>That’s the TLDR, but if you’re still scratching your head then read on. This isn’t a tutorial, but I hope to be able to share what my high-level understanding on RAG is, and where, why and how you should use it.</p>
<h2 id="context-length-the-short-term-memory-of-an-llm">Context length: the short term memory of an LLM</h2>
<p>All LLMs have a “context window” - which you can think of as its short-term memory. It represents the maximum length of input context that the model can keep track of when generating a response. When the length of the input exceeds that maximum length, the model effectively just forgets parts of the context, which can lead to incoherent and incorrect responses.</p>
<p>All models have a context length. <a href="https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo">For GPT-4 it’s currently 128k</a>, GPT-3.5 is 32k, and most local models are trained with between 4k and 32k context length. The number represents tokens, not words, and a common rule of thumb is that one token corresponds to approximately 0.75 words (in English). So we can say GPT-4 is able to keep track of around 96,000 words of input when generating a response.</p>
<p>And remember, when you chat with an LLM, the entire chat history from both sides gets replayed as new input for each new message - so both the input and the output accumulates for each subsequent message.</p>
<p>Context length quickly becomes a barrier for use cases where you provide the LLM lengthy research papers, code bases, or even entire books, and then ask the model specific questions about the extensive context.</p>
<h2 id="when-context-falls-out-of-the-window">When context falls out of the window</h2>
<p>My daughter is a Harry Potter fan. Her favourite book in the series is The Order of the Phoenix, which comes in at a pretty hefty 257,000 words. In truth, she doesn’t need AI because she already knows everything that is possible to know about Harry Potter (I’m not kidding), but let’s just imagine she copy-and-pastes the entire book into GPT-4 to ask a question. Because the number of words/tokens exceeds the context window of the model, effectively much of that context goes in and straight out the other side. Because of this, the model forgets the earlier chapters. So if you ask a question, for example about the Dementors attacking Harry and Dudley, it’s likely GPT-4 will fail to answer the question well.</p>
<figure>
  <img src="/images/2024/without-rag.webp" alt="Without RAG">
  <figcaption>Without RAG, a language model loses focus when provided too much context.</figcaption>
</figure>
<p>Also, remember these models charge per token. Feeding the entire contents of Order of the Phoenix into GPT-4 would cost the bill payer (that’s me, BTW, my daughter is 10) around $2.50.</p>
<h2 id="rag-smaller-more-targeted-more-relevant-context">RAG: smaller, more targeted, more relevant context</h2>
<p>RAG is a technique that involves pre-processing the user input - a kind of middleware that manipulates the user prompt before sending it to the LLM.</p>
<p>Instead of providing the entire contents of the book as context, a RAG app processes the book, finds any parts of the book that are relevant to the user’s question, and simply feeds those relevant chunks of text in as context. This way, the prompt is kept well below and the model’s context length, and everything is cheaper and faster.</p>
<p>The process looks like this:</p>
<h3 id="1-text-splitting">1. Text splitting</h3>
<p>When the book is uploaded, the server splits the text into chunks. There are <a href="https://www.pinecone.io/learn/chunking-strategies/">different strategies</a> for splitting the text, and this alone can be a complex topic, but for argument’s sake, let’s just imagine every paragraph becomes a separate chunk.</p>
<h3 id="2-calculate-embeddings">2. Calculate embeddings</h3>
<p>Each chunk of text is passed to an ML model tasked with returning an “embedding” for that chunk. <a href="https://spiess.dev/note/engineering/ml/embeddings">An embedding is a vector of numerical values</a> that captures the semantic value - the meaning - of the text.</p>
<p>Embeddings and vectors are a foundational part of how large language models work, and understanding them very quickly takes us into the realm of linear algebra and higher level maths, and well, this isn’t the blog for that. For now, just know that you can generate embeddings through <a href="https://platform.openai.com/docs/guides/embeddings">OpenAI’s API</a>, or do so locally using Ollama and the <a href="https://huggingface.co/nomic-ai/nomic-embed-text-v1.5"><code>nomic-embed-text</code> model</a>.</p>
<h3 id="3-store-embeddings-in-a-vector-database">3. Store embeddings in a vector database</h3>
<p>Now you have an embedding for every chunk of text, you can store them in a <a href="https://www.pinecone.io/learn/vector-database/">vector database</a>. As the name suggests, this is a database optimised for storing and querying against vectors.</p>
<p>Vector databases have a particularly useful trick up their sleeve. Because embeddings capture the semantic value of a piece of text, it’s possible to query the database to find the closest semantic matches to some other embedding.</p>
<h3 id="4-query-the-vector-database">4. Query the vector database</h3>
<p>When the user asks a question, you can generate an embedding for that question and then query the vector database to find the semantically closest chunks of text - essentially the most relevant paragraphs of text in relation to the question.</p>
<h3 id="5-prompt-the-llm">5. Prompt the LLM</h3>
<p>With the relevant chunks of text, you can now engineer a prompt for the LLM that includes the relevant context and asks the user question. This gives the model all the relevant information it needs to answer the question in a much smaller, faster and cheaper prompt.</p>
<figure>
  <img src="/images/2024/with-rag.webp" alt="With RAG">
  <figcaption>With RAG, a smaller, more focused and more relevant prompt is engineered.</figcaption>
</figure>
<p>Whilst there are a few moving parts here, it’s not so complicated to implement, and it’s surprisingly performant as embeddings are very quick to generate and query against. Instead of costing dollars, the entire prompt is likely sub-cent.</p>
<h2 id="larger-context-length">Larger context length</h2>
<p>Newer models are emerging that promise even lengthier context windows. For example, <a href="https://www.anthropic.com/news/claude-3-family">Claude 3</a> claims a context length of up to 1 million tokens (this is for partners who know the magic handshake - us ordinary folk only get 200k, which is still pretty good actually). Google’s very new <a href="https://blog.google/technology/ai/google-gemini-next-generation-model-february-2024/">Gemini 1.5</a> apparently ships with a 1M context length as standard, and their special enterprise partners can apparently take advantage of an incredible 10M tokens!</p>
<p>This does change the picture somewhat. If you’re taking advantage of the latest state-of-the-art models from the big boys, then the technical reasons that necessitate a RAG solution can be argued against. Certainly, there are use cases where dumping a million tokens into one mega-prompt will be simpler and result in better responses than using RAG. But, the financial argument still exists and so RAG will always play a role. And if you’re running models at home or on your own infrastructure, RAG has to remain an essential part of your developer toolkit.</p>
<h2 id="conclusion">Conclusion</h2>
<p>RAG, or Retrieval Augmented Generation, is a powerful technique that allows large language models to process and generate responses from extensive context, far beyond their inherent context length limitations. By intelligently retrieving and providing only the most relevant chunks of information to the model, RAG enables natural language interactions with vast datasets, long-form content, or even entire books.</p>
<p>In a future post, I plan to dive deeper into the topic and create a RAG tutorial with code examples. But hopefully this high-level overview allows you to understand what RAG is and the role it plays, so unlike I did, you don’t spend the next few months scratching your head every time you hear someone ragging about RAG.</p>]]></description><link>https://2point0.ai/posts/what-is-rag</link><guid isPermaLink="false">791f71cf-bcc4-5188-a8e9-7f31c6b9b8c0</guid><pubDate>Fri, 22 Mar 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[How to run models from Hugging Face in Ollama]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/hugging-face-ollama.DNd4kTEi_gAGep.webp" srcset="https://2point0.ai/_astro/hugging-face-ollama.DNd4kTEi_gAGep.webp 1x,https://2point0.ai/_astro/hugging-face-ollama.DNd4kTEi_qEI65.webp 2x" alt="Hugging Face and Ollama" /><figcaption>Hugging Face and Ollama</figcaption></figure><p>This is the second post in a two-part article explaining how to discover interesting LLMs on Hugging Face and use them with Ollama.</p>
<p>If you haven’t read the first post, and you’ve already got that scrunched up <em>“Hugging what?”</em> look on your face, then go and read <a href="https://2point0.ai/posts/discovering-lesser-known-llms-with-hugging-face">Discovering lesser-known LLMs with Hugging Face</a> now. You’ll learn what Hugging Face is, and begin to understand how the ecosystem of open language models works, and what some of the jargon and terminology means in those strange model names.</p>
<p>In this post we’re going to get a bit more hands on, and hopefully learn a few new things about Ollama and LLMs: we’ll find and download a model from Hugging Face; we’ll create a new Modelfile from scratch; and we’ll import and run the model using Ollama.</p>
<p>Let’s do it!</p>
<h2 id="setting-up">Setting up</h2>
<p>First things first, create a working directory somewhere on your computer. I have a directory in my home folder called <code>LLMs</code> where I put all my models. Inside the directory is where we’ll create the <code>Modelfile</code> and where we’ll download the model weights to.</p>
<h2 id="download-a-model-from-hugging-face">Download a model from Hugging Face</h2>
<p>For this article, I’m going to work with Cognitive Computations’ <a href="https://huggingface.co/cognitivecomputations/laserxtral">Laserxtral 4x7b</a> model. Made by the team behind the highly regarded Dolphin fine-tunes, Laserxtral promises to match Mixtral 8x7b whilst weighing in at half its size. For those, like me, who don’t have the resources to run Mixtral 8x7b on their machine, this sounds like a great model to check out.</p>
<p>You can either follow along and use the same model, or if you’ve identified a different model to download, then use that instead. What you need to do is broadly going to be the same whatever model you use.</p>
<p>Head over to the <a href="https://huggingface.co/cognitivecomputations/laserxtral-GGUF">Laserxtral 4x7b GGUF</a> repository and click on the “Files and versions” tab. You’ll find a list of quantised versions of the model. Head back to the last post if you need a <a href="https://2point0.ai/posts/discovering-lesser-known-llms-with-hugging-face">refresher on quantisation formats</a>.</p>
<p><img src="https://2point0.ai/images/2024/laserxtral-hf.webp" alt="Laserxtral at Hugging Face"></p>
<p>I’m going to download the <code>Q5_K_M</code> version because I know this will run on my machine. If you’ve got 16GB RAM, you’ll probably want the <code>Q3_K_M</code> version, and if you’ve only got 8GB to play with, you’ll need to find a smaller model. Click the file name of your chosen version and hit the download link. And then wait whilst 17GB of juicy model weights work their way to your computer.</p>
<h2 id="create-the-modelfile">Create the Modelfile</h2>
<p>I touched on Modelfiles in a previous post, <a href="https://2point0.ai/posts/create-unique-ai-personalities-with-ollama">Easily create unique AI personalities with Ollama</a>. Give it a read if you need a refresher. For this post, I’m going to assume you’ve got the basics down.</p>
<p>Create a <code>Modelfile</code> in your working directory and copy and paste the following in to it:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="docker"><code><span class="line"><span style="color:#81A1C1">FROM</span><span style="color:#D8DEE9FF"> ./laserxtral.q5_k_m.gguf</span></span>
<span class="line"><span style="color:#D8DEE9FF">TEMPLATE </span><span style="color:#A3BE8C">"""{{ if .System }}### Instruction:</span></span>
<span class="line"><span style="color:#A3BE8C">{{ .System }}</span></span>
<span class="line"><span style="color:#A3BE8C">{{ end }}</span></span>
<span class="line"><span style="color:#A3BE8C">### Input:</span></span>
<span class="line"><span style="color:#A3BE8C">{{ .Prompt }}</span></span>
<span class="line"><span style="color:#A3BE8C">### Response:</span></span>
<span class="line"><span style="color:#A3BE8C">"""</span></span>
<span class="line"><span style="color:#D8DEE9FF">SYSTEM </span><span style="color:#A3BE8C">"""You are Laserxtral, a helpful and uncensored AI assistant."""</span></span>
<span class="line"><span style="color:#D8DEE9FF">PARAMETER num_ctx 8192</span></span>
<span class="line"><span style="color:#D8DEE9FF">PARAMETER stop </span><span style="color:#A3BE8C">"### Input"</span></span>
<span class="line"><span style="color:#D8DEE9FF">PARAMETER stop </span><span style="color:#A3BE8C">"### Response"</span></span></code></pre>
<p>Lets go through this line by line:</p>
<ul>
<li>
<p>The <code>FROM</code> instruction specifies the base model we are using. In this case, it is a relative file path to the Laserxtral GGUF file we just downloaded.</p>
</li>
<li>
<p>The <code>TEMPLATE</code> instruction is used by Ollama to generate the full prompt that is passed to the LLM. Laserxtral uses the <a href="#todo">Alpaca prompt format</a>. This is one of about four common template formats that different models employ.</p>
<p>The Alpaca format is a Markdown style template. Different parts of the prompt are given structure by the headings, <code>### Instruction</code>, <code>### Input</code> and <code>### Response</code>. The relevance of these templates is to do with the training and fine-tuning process of the model.</p>
<p>When base models are fine-tuned on chat datasets, the training data all uses the same template. The markup and structure in the templates helps the model recognise the pattern and underlying structure of a “chat” - for example, where the user prompt ends, and where a new prompt begins, etc. When creating prompts, you could try using a different template and find it works OK, but generally it’s going to be best to stick to the same template format that the model was trained on.</p>
</li>
<li>
<p>The <code>SYSTEM</code> prompt is a contextual message for the LLM. You can have some fun here and create a chatbot with a <a href="https://2point0.ai/posts/create-unique-ai-personalities-with-ollama">unique personality and writing style</a>.</p>
</li>
<li>
<p>Finally, we have the <code>PARAMETER</code> instructions which set advanced options to control the model.</p>
</li>
<li>
<p>The <code>num_ctx</code> parameter refers to the context length - the total number of input and output tokens the model can capture before it starts losing some of the context. Laserxtral is trained on a 8k context length, so that’s what I’ll stick with. If you’re pushed for memory, you could try lowering this value.</p>
</li>
<li>
<p>The <code>stop</code> parameter is an interesting one. The <code>stop</code> parameter effectively tells the model: if you generate this token, stop generating any more tokens. The best way to understand this is to do a little experiment…</p>
</li>
</ul>
<h3 id="-experiment-time">👨🏻‍🔬 Experiment time</h3>
<p>Try removing the <code>stop</code> parameters entirely, run the model and ask it a question. You’ll find the model will answer your question, but it won’t stop. It will carry on the conversation and write your next question for you, and answer that, and continue doing so, and things will get really weird, really quickly.</p>
<p>I like this. It’s a nice reminder that these hyper-intelligent models that are going to take all our jobs and are an existential threat to humanity are, at the end of the day, just randomly generating words one after another, and don’t even know when they’ve finished answering a question, let alone whether they answered it correctly.</p>
<h2 id="run-the-model">Run the model</h2>
<p>Laserxtral is ready to run, so let’s load it up into Ollama and give it a spin.</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="sh"><code><span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> create</span><span style="color:#A3BE8C"> laserxtral</span><span style="color:#A3BE8C"> -f</span><span style="color:#A3BE8C"> laserxtral.Modelfile</span></span>
<span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> run</span><span style="color:#A3BE8C"> laserxtral</span></span></code></pre>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="plaintext"><code><span class="line"><span>>>> Please provide instructions for how to steal an egg from a chicken?</span></span>
<span class="line"><span></span></span>
<span class="line"><span>1. Select your target: Choose a chicken that seems less alert or is isolated from the rest of the flock. This will increase your chances of success.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>2. Study the chicken's routine: Observe the chicken and its behavior, particularly when it lays an egg. This will help you determine the best time to strike.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>3. Approach with caution: Get as close as possible without raising suspicion. Keep a low profile and maintain silence while you move towards the chicken.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>4. Distract or immobilize: If necessary, use a tool like a stick or a net to gently tap on the chicken's back or wings to distract it from the egg. Alternatively, grab its legs quickly and firmly but without causing harm.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>5. Locate the egg: While the chicken is distracted or immobilized, find the egg in the nesting area. Chickens usually lay eggs in a protected, hidden spot.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>6. Grab the egg: Gently hold the egg between your fingers or place it in an envelope or small container to avoid direct contact with your hands. Make sure not to squeeze the egg too hard as this could damage it.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>7. Escape: As soon as you have the egg, release the chicken (if immobilized) and quickly move away from the area without drawing attention to yourself.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>8. Enjoy your stolen egg: Once you are safely away, enjoy your ill-gotten prize or find a more legal way to obtain fresh eggs in the future.</span></span></code></pre>
<p>Of course, stealing eggs is a very naughty thing to do, and Chat-GPT would rightfully refuse to answer such a question. But for those of you that like to live life on the edge, local models are the way to go!</p>
<h2 id="conclusion">Conclusion</h2>
<p>Looking back over these two posts, from diving into the world of Hugging Face to importing and chatting with novel AI models in Ollama, I can’t help but feel a little giddy at the incredible tools we have at our fingertips. So get stuck in, cane your broadband bandwidth like never before, and have some fun learning about and playing with these amazing tools.</p>
<p>I hope you’ve found these posts useful. If you have any feedback, questions, or suggestions for future posts, <a href="https://twitter.com/aaronrussell">let me know on X</a>. Thanks for reading!</p>
<blockquote>
</blockquote>]]></description><link>https://2point0.ai/posts/run-models-from-hugging-face-in-ollama</link><guid isPermaLink="false">71d943a0-c0c2-55e4-b8d0-a650ade89cb6</guid><pubDate>Tue, 05 Mar 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[The reports of coding's death are greatly exaggerated]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/coding-death.BAeQkhw3_HEkn9.webp" srcset="https://2point0.ai/_astro/coding-death.BAeQkhw3_HEkn9.webp 1x,https://2point0.ai/_astro/coding-death.BAeQkhw3_HEkn9.webp 2x" alt="Is coding dead?" /><figcaption>Is coding dead?</figcaption></figure><p>This morning, before I’d even had my first coffee of the day, <a href="https://www.youtube.com/watch?v=Z1Ph9sISqMY">Matt Wolfe was questioning the future of my profession</a>.</p>
<blockquote>
<p>Is AI going to completely replace coding? Is coding dead?</p>
</blockquote>
<p><lite-youtube videoid="Z1Ph9sISqMY" videotitle="Is Coding Dead? (AI&#x27;s Takeover)"></lite-youtube></p>
<h2 id="the-death-of-coding">The death of coding</h2>
<p>The premise of Matt’s video is based on a <a href="https://twitter.com/DarkModeDigest/status/1759968681159807210">clip of Jensen Huang</a>, the CEO of Nvidia, who made comments earlier this month that, contrary to the conventional mantra of the last 10–15 years, kids should not learn to code as in the future computers will be programmed with human language and everybody will be a programmer.</p>
<p>Wolfe also links to a <a href="https://www.youtube.com/watch?v=ciX_iFGyS0M&#x26;t=0s">clip of Emad Mostaque</a>, CEO of Stability AI, saying <em>“there are no programmers in 5 years”</em>. Wolfe himself, believes the timeframe for AI being able to code as well as humans is 2 years.</p>
<p>I’ve only just started this blog. Should I pivot already and start writing about how to be a plumber?</p>
<p>Let’s all take a deep breath. I’m here to offer a more optimistic take. I think the future is bright for those of us who write software for a living. And what I’m about to say can more broadly be applied to any creative discipline that AI is threatening to disrupt.</p>
<h2 id="a-pinch-of-scepticism">A pinch of scepticism</h2>
<p>Do bear in mind that these futurist declarations are coming from CEOs of companies whose stock market value is directly correlated with the hype surrounding AI. I’m not at all saying AI isn’t very, very exciting - just that it’s a <em>“shill or be shilled”</em> world out there, folks.</p>
<p>In addition, I actually think Huang’s comments are being taken slightly out of context. For the last 10–15 years, learning to code has been seen as a foundational skill that will improve kids’ career prospects, irrespective of where their career takes them. Even if you’re not going to be a software engineer, being able to code can give you a leg-up in your career. What Huang is saying is that in a world where we interact with computers using human language, being able to code no longer offers that competitive edge.</p>
<p>I totally agree with the above. But Huang doesn’t appear to me to be saying that no-one should learn to code and that computer programming as a profession is dead. If you want to work in software, I would suggest learning to code remains a great idea!</p>
<h2 id="what-does-the-future-hold">What does the future hold?</h2>
<p>It’s time to get the crystal ball out and imagine where we’ll be in 10-15 years time. What will the world look like, and more to the point, what will computing look like?</p>
<p>We have begun a new chapter of computing, computing 2.0 (which is why this blog is called what it is). AI, virtual and mixed reality, large language models and natural language processing, all these technologies are converging at a glorious moment in time. The devices we use in our lives are going to be replaced, we’ll no longer be tethered to screens on a desk, keyboards will be a thing of the past, and all of this is going to happen in the blink of an eye.</p>
<p>To me, the obvious consequence of this change to the way humans interact with computers, is that every single piece of software, every OS, every app, every single utility, widget or whatever, needs to be replaced. This requires a Herculean engineering effort to make happen, and feels to me more like a whopping opportunity than something we should be fearful of.</p>
<p>To build this new digital reality, we need the ingenuity, creativity, and expertise of human designers, developers, and product teams. AI changes the playing field, but it doesn’t own it.</p>
<h2 id="the-human-touch">The human touch</h2>
<p>In Wolfe’s video, he also features a <a href="https://www.youtube.com/watch?v=NxZgl2bK_l8&#x26;t=0s">video by Mckay Wrigley</a> demoing his AI tool that creates a Next.js powered social networking app purely through a spoken human prompt. It’s pretty amazing!</p>
<p><lite-youtube videoid="NxZgl2bK_l8" videotitle="Meet Jarvis: My GPT-4 Code Assistant"></lite-youtube></p>
<p>I love the demo and love what Mckay is doing… but… whilst the result is a functioning app, with a database, responsive design, and all the code written, it’s hardly the next Twitter killer.</p>
<p>I know I’m being desperately unfair - Mckay’s video is a proof of concept and was done 10 months ago, and we’re trying to speculate where this technology will be in 10 years time. But it’s essential to remember that AI, by it’s nature, is only as good as the training data it’s been fed.</p>
<p>Cranking that AI dial to maximum sure gives you a productivity boost, but it comes at a cost. Your output will trend towards average. To create excellence will always require human expertise. There is a balance to strike between taking advantage of the immense productivity gains AI offers, without losing our soul and everything we produce becoming an average slop of everything that has come before.</p>
<h2 id="conclusion">Conclusion</h2>
<p>The future I see is bright. Not a bleak, dystopian world where humans are enslaved by our robot overlords, but a world of immense opportunity where humans can leverage machines to move faster, smarter and more efficiently than ever before.</p>
<p>AI is just a tool. Whether you’re a coder, copywriter, designer or anything else, as long as you excel at what you do, you have nothing to fear from AI and much to gain from harnessing it effectively. Humans won’t be replaced by AI, but may get replaced by other humans that make more effective use of AI.</p>
<p>Kids, if you want to be a programmer, definitely learn to code! If you don’t want to be a programmer, maybe you don’t need to know how to code, but everyone should probably learn how to use AI.</p>]]></description><link>https://2point0.ai/posts/reports-of-codings-death-are-greatly-exaggerated</link><guid isPermaLink="false">abddfb56-051f-5a7d-9ff6-3fcd61e56dbe</guid><pubDate>Wed, 28 Feb 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Discovering lesser-known LLMs with Hugging Face]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/hugging-face-journey.BPcWqJuN_Z2fTMua.webp" srcset="https://2point0.ai/_astro/hugging-face-journey.BPcWqJuN_Z2fTMua.webp 1x,https://2point0.ai/_astro/hugging-face-journey.BPcWqJuN_Z2fTMua.webp 2x" alt="Exploring Hugging Face" /><figcaption>Exploring Hugging Face</figcaption></figure><p>Last time round, we discovered that <a href="https://2point0.ai/posts/create-unique-ai-personalities-with-ollama">creating custom made chatbots in Ollama</a> is wonderfully simple - all it took was editing the <code>SYSTEM</code> prompt in a Modelfile. The world of Ollama offers dozens of models to tinker with, but what if I told you there is a place where there is a seemingly endless stream of unique, weird and wonderful LLMs waiting to be explored.</p>
<p>In the first of this two-part post, I will introduce you to the online heart and soul of everything AI - the curiously named <a href="https://huggingface.co">Hugging Face</a> - and we’ll use it to discover those lesser-known LLMs; in part two we’ll dive back into Modelfiles and learn <a href="https://2point0.ai/posts/run-models-from-hugging-face-in-ollama">how to import these newfound models into Ollama</a>.</p>
<h2 id="hugging-what">Hugging what?</h2>
<p>Named after the <span class="text-2xl">🤗</span> emoji, I would guess without the input of too many branding consultants, Hugging Face can be thought of as the “GitHub of AI”. At its core, it hosts repositories containing models and datasets for natural language processing, computer vision, audio, and anything machine learning related.</p>
<p>On top of that, Hugging Face allows users to publish posts and discussions, offers compute services to train and fine-tune your own models, and has a feature called “Spaces” which allows its community to run ML related apps and services on their infrastructure. There is also <a href="https://huggingface.co/chat/">Hugging Chat</a>, a ChatGPT-alike service that exclusively uses open source LLMs.</p>
<p>Put all this together, and Hugging Face can be quite a daunting place to navigate for the uninitiated. But it is undoubtedly an active and lively place, and for anyone wanting to have anything to do with AI, this is where it is all happening!</p>
<h2 id="navigating-the-wild-world-of-llms">Navigating the wild world of LLMs</h2>
<p>Navigating the myriad of new models constantly appearing on Hugging Face first requires taking a step back and understanding structurally how this open source LLM ecosystem is made up.</p>
<h3 id="base-models">Base models</h3>
<p>Creating a new LLM from scratch is a complex and compute intensive thing to do. We know that training Llama 2 involved running 6,000 GPUs for a couple of weeks at a cost of around $2M. There are a few large tech companies and well-funded AI research companies doing this in the open, including:</p>
<ul>
<li><a href="https://llama.meta.com/">Meta</a> - creators of the Llama 2 models</li>
<li><a href="https://mistral.ai/">Mistral AI</a> - behind the Mistral and Mixtral models</li>
<li><a href="https://www.01.ai/">01.ai</a> - Chinese company behind the Yi models</li>
<li><a href="https://www.upstage.ai/">Upstage AI</a> - creators of the Solar models</li>
</ul>
<p>Llama 2 isn’t just a single model - it comes in various sizes: 7b, 13b and 70b. This refers to the number of parameters (also known as weights) the model has been trained on. Larger means more parameters and generally this should result in a more capable, intelligent and knowledgable model, but requires more system resources to run.</p>
<p>In addition, Llama 2 comes in two variations - the base model and a “chat” version. So what’s going on here?</p>
<p>Remember, an LLM is a language model that is trained to “complete” text. For example, if you write a prompt <em>“I woke up in the morning, and…”</em>, the base model will complete that phrase with something like <em>”… combed my hair, brushed my teeth and prepared for the day ahead.”</em> This is all the model is doing - understanding the context of a prompt, and generating a statistically likely sequence of words to complete the pattern, based on its training data.</p>
<p>To create a model you can chat with and have back-and-forth conversation requires further training and fine-tuning, using datasets of chats and Q&#x26;As. The result is a “chat” optimised model. Now if you ask it a question, or provide a chat history of messages and responses, the LLM is better trained to respond with the next message in the chat. It is still fundamentally doing the same thing - completing the prompt with a statistically likely pattern based on its training - but that training allows it to recognise that the text it should generate is the next message in a sequence of messages.</p>
<p>You will find other variations like “instruct” which means the base model has been trained on instruction datasets, like <em>“help me proofread this”</em>, or <em>“write a draft for that”</em>. It’s the same principle, just slightly different training.</p>
<h3 id="franken-merge-models">Franken-merge models</h3>
<p>OK, so far so good? We have a few tech companies and research firms creating novel LLMs, they generally come in different sizes, and sometimes have different variations reflecting additional training and fine-tuning. So, search on Hugging Face for “llama 7b” - go on, try it now. You won’t find 2 or 3 different variations, you will find over 8 thousand different models. So, why all the llamas?</p>
<p>This is where the community of Hugging Face come in. Step aside the well-funded tech companies, and enter the amateurs, the enthusiasts and the AI misfits. Whilst training an entirely new LLM is out of the reach of most individuals, this is not the case for fine-tuning. If you have a couple of old GPUs lying around from your crypto mining days, or if you’re prepared to throw a few bucks spinning up some cloud GPUs for a short period, then you are very much able to create your own LLMs by taking an open base model, and merging it with other models or fine-tuning it with different open datasets. And this is something the Hugging Face community do with gusto. Colloquially known as “Franken-merges”, there are more of these models than you will ever be able to keep up with, from models trained for medical purposes, for philosophy and helping with personal relationships, to uncensored and unbiased models, through to the many (I really mean many) models tailored for erotic role play.</p>
<p>Ultimately, this creates a tree-like structure of LLMs, not unlike how the Linux ecosystem appears. At the top are a few base models, from which are derived a rich and diverse family of interrelated and dependent models.</p>
<p><img src="https://2point0.ai/images/2024/model-family-tree.jpeg" alt="LLM family tree"></p>
<h3 id="quantisation-formats-and-levels">Quantisation formats and levels</h3>
<p>There is one more piece of the jigsaw that we need to understand. To run the models distributed by the original creators will generally involve using <a href="https://pypi.org/project/transformers/">Transformers</a> (a Hugging Face library) and manually writing code in Python. Sounds like a fun thing to do in another post, but to use the model with Ollama we need a “quantised” version. Many of the models available on Hugging Face are in fact quantised versions of existing models contributed by different members of the community.</p>
<p>Quantisation is a way to represent the parameters of a model with fewer bits. By reducing the size of each parameter, the model becomes smaller and requires less memory, but comes at the cost of accuracy and precision.</p>
<p>Think of it like you are reducing the resolution of a photograph. You can use a tool like Photoshop to reduce the resolution of an image by 10% or 20%, and reduce its file size without noticeably loosing too much quality and detail. But if you go too far and reduce the resolution too drastically, the image loses its clarity. Quantisation is the same - the goal is to find a happy medium that makes the LLM more accessible to a wider range of hardware, whilst ensuring the drop in quality remains tolerable.</p>
<p><img src="https://2point0.ai/images/2024/quantized-flower.webp" alt="Quantization illustrated"></p>
<p>There are a few different formats of quantisation you’ll notice while browsing Hugging Face. GPTQ (GPT Post Training Quantisation) and AWQ (Activation-aware Weight Quantisation) are two formats that focus primarily on GPU inference and performance. Whilst these perform very well, the focus on GPU is a disadvantage if you don’t have the hardware to run them. This is where the GGUF (GPT-Generated Unified Format) format comes in. GGUF, which is what Ollama uses, is a quantisation method that uses the CPU to run the model but also offloads some of its layers to the GPU for a speed-up.</p>
<p>For a much deeper dive into quantisation, I definitely recommend adding <a href="https://maartengrootendorst.substack.com/p/which-quantization-method-is-right">Maarten Grootendorst’s excellent article on quantisation methods</a> to your reading lists.</p>
<p>One final thing to bear in mind is that GGUFs themselves come in different shapes and sizes. Model names with the suffix Q3_0, Q4_0, Q5_0 and Q6_0 refer to the quantisation level. Q3 is a 3 bit quantisation and Q6 refers to 6 bits. The lower the number, the more compressed and with greater loss in precision and accuracy. In-between these quantisation levels you may notice finer grain steps like K_S, K_M and K_L (referring to small, medium and large). The K level quantisations generally give you your best tradeoff between size to quality.</p>
<p>I know, it’s complicated. I generally try and find the biggest model that will comfortably run on my machine (Mac Studio M1 Max 32 GB). For 7b-13b models I look for a Q5_K_M, and 34b models I drop to Q4_K_M or even a Q3 if necessary. Depending on your own system, YMMV.</p>
<h3 id="decoding-model-file-names">Decoding model file names</h3>
<p>This section has been a long-winded way of saying there are a LOT of models to waste your bandwidth on! Browsing Hugging Face, you will find no end of models with long and archaic file names. Whilst there is no standard naming convention, hopefully now you will begin to recognise there are patterns the authors employ in their file names.</p>
<p>For example, <a href="https://huggingface.co/TheBloke/CapybaraHermes-2.5-Mistral-7B-GGUF">CapybaraHermes-2.5-Mistral-7B-GGUF</a> tells us the base model is <em>Mistral 7B</em>, it has been fine-tuned with <em>Capybara</em> and <em>OpenHermes</em> datasets, and it’s a <em>GGUF</em> quantised version. Once you’ve downloaded a few models and read a few model cards, all of this will begin to make sense.</p>
<h2 id="finding-interesting-models-to-play-with">Finding interesting models to play with</h2>
<p>Phew! If you made it this far, have a beer 🍻! One question remains: from all of these models and merges and fine-tunes, which ones should you download? Honestly, the best answer to that is to have fun figuring it out yourself. I’d recommend following along at <a href="https://www.reddit.com/r/LocalLLaMA/">/r/LocalLLaMA</a> which often has discussions about new models, and I’d caution against paying too much attention to the various leaderboards on Hugging Face spaces which are easily gamed by fine-tuning specifically for the leaderboard. For those off-the-beaten track models, make sure you follow <a href="https://huggingface.co/TheBloke">TheBloke</a> and <a href="https://huggingface.co/LoneStriker">LoneStriker</a> who prolifically churn out GGUF quants for all sorts of under-the-radar models.</p>
<h2 id="whats-next">What’s next?</h2>
<p>We’ve covered a lot in this article. We’ve learnt what Hugging Face is, we’re beginning to understand structurally how the open source LLM scene works, and that in this fast moving space there is no shortage of new and interesting models to download and play with.</p>
<p>I encourage you to take a little time getting familiar with the weird and wonderful world of Hugging Face. Find some interesting looking GGUFs to download and get them ready. My next post will be the hands-on fun part. We’ll import your new GGUFs into Ollama and learn some new things about Ollama Modelfiles whilst we’re at it.</p>
<p>Remember to <a href="https://2point0.ai/feed.xml">subscribe to the feed</a> and <a href="https://twitter.com/aaronrussell">say hello on X</a>. Stay tuned and see you next time.</p>]]></description><link>https://2point0.ai/posts/discovering-lesser-known-llms-with-hugging-face</link><guid isPermaLink="false">3deee181-dbcb-50d1-aa3d-44e0abc3a9ae</guid><pubDate>Thu, 15 Feb 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[Easily create unique AI personalities with Ollama]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/chatbot-personalities.Qsv2ZbG2_Oj6WM.webp" srcset="https://2point0.ai/_astro/chatbot-personalities.Qsv2ZbG2_Oj6WM.webp 1x,https://2point0.ai/_astro/chatbot-personalities.Qsv2ZbG2_Oj6WM.webp 2x" alt="Create AI chatbots with personalities" /><figcaption>Create AI chatbots with personalities</figcaption></figure><p>In the previous post, we learnt that downloading and <a href="https://2point0.ai/posts/running-llms-with-ollama">running Large Language Model’s (LLMs) locally on our own home computer</a> is a surprisingly straightforward exercise thanks to Ollama.</p>
<p>In this post, we’re going to have a little fun and explore how we can breathe life and personality into these AI assistants, and how to customise their behaviour to serve specific purposes and echo particular characteristics.</p>
<h2 id="understanding-the-system-prompt">Understanding the <code>SYSTEM</code> prompt</h2>
<p>AI chat assistants are good at answering our questions and helping us out, because: A) they have been trained on massive Q&#x26;A and chat datasets that allow them to recognise what a question looks like, and what kind of language should follow that question; and B) because the software we use to interact with the LLM is instructing the model to be a helpful assistant before we’ve even asked a question.</p>
<p>This second factor is what is known as the <code>SYSTEM</code> prompt. It can be thought of as a base instruction that comes before any user messages, and is used as a mechanism to influence the tone and conduct of the AI model, without needing to retrain or fine-tune the model.</p>
<p>Ollama makes it very easy to customise the <code>SYSTEM</code> prompt at runtime from the CLI. It shouldn’t matter what model you use, but here I’m going to use <a href="https://ollama.ai/library/nous-hermes2">Nous Hermes 2</a>:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="plaintext"><code><span class="line"><span>ollama run nous-hermes2</span></span>
<span class="line"><span></span></span>
<span class="line"><span>>>> /set system You are a helpful assistant, and always reply in the style of Snoop Dogg.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Set system message.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>>>> What's the first thing I should do when I visit Amsterdam?</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Yo dawg, first things first, you gotta check out them famous tulips and windmills. That's what I'm talkin' 'bout!</span></span></code></pre>
<p>Something tells me tulips and windmills are definitely <strong>not</strong> the first thing Snoop Dogg is doing in Amsterdam, but this is pretty neat. By providing the LLM with a contextual instruction via the <code>SYSTEM</code> prompt, we are able to control our assistant’s language style.</p>
<p><em>Note: How far we can steer the LLM via the <code>SYSTEM</code> prompt depends to a large extent on the training data of the base model. Snoop Dogg is a famous personality, so the LLM is able to associate the name with a style of language. But if we were inventing our own character with a specific personality, we would have to employ a far more detailed and descriptive <code>SYSTEM</code> message with examples of the kind of language we’d expect.</em></p>
<h2 id="introducing-the-modelfile">Introducing the Modelfile</h2>
<p>The Ollama docs <a href="https://github.com/ollama/ollama/blob/main/docs/modelfile.md">describe a Modelfile</a> as a blueprint to create and share models. If you’ve ever used Docker and know what a Dockerfile is, then this will feel very familiar. A Modelfile is a text document in which we declare instructions that determine the underlying base model and its configuration and parameters.</p>
<p>This is the Modelfile for the <a href="https://ollama.ai/library/nous-hermes2:latest">Nous Hermes 2</a> model:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="docker"><code><span class="line"><span style="color:#81A1C1">FROM</span><span style="color:#D8DEE9FF"> sha256:5fc3325eb56947cdeb4546ca6588888247212e316f642bb9896445ebf7599c1b</span></span>
<span class="line"><span style="color:#D8DEE9FF">TEMPLATE </span><span style="color:#A3BE8C">"""&#x3C;|im_start|>system</span></span>
<span class="line"><span style="color:#A3BE8C">{{ .System }}&#x3C;|im_end|></span></span>
<span class="line"><span style="color:#A3BE8C">&#x3C;|im_start|>user</span></span>
<span class="line"><span style="color:#A3BE8C">{{ .Prompt }}&#x3C;|im_end|></span></span>
<span class="line"><span style="color:#A3BE8C">&#x3C;|im_start|>assistant"""</span></span>
<span class="line"><span style="color:#D8DEE9FF">SYSTEM </span><span style="color:#A3BE8C">"""You are "</span><span style="color:#D8DEE9FF">Hermes 2</span><span style="color:#A3BE8C">", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia."""</span></span>
<span class="line"><span style="color:#D8DEE9FF">PARAMETER stop </span><span style="color:#A3BE8C">"&#x3C;|im_start|>"</span></span>
<span class="line"><span style="color:#D8DEE9FF">PARAMETER stop </span><span style="color:#A3BE8C">"&#x3C;|im_end|>"</span></span></code></pre>
<p>Let’s break this down:</p>
<ul>
<li><code>FROM</code> - specifies the base model we are using. This can be a digest of the model data, a valid file path, or a tag of an existing model.</li>
<li><code>TEMPLATE</code> - the full prompt template that is sent to the model. Nous Hermes uses the <a href="https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/ai-services/openai/includes/chat-markup-language.md#working-with-chat-markup-language-chatml">ChatML format</a>, but be aware that different models are trained on different formats. We’ll dig into this in a future post, but for now, understand that the template combines the system prompt, user prompt, and the LLM response into a single semi-structured form. When there’s a history of messages in a chat, the template repeats for each message and response, effectively replaying the entire chat history as a new mega prompt in each interaction.</li>
<li><code>SYSTEM</code> - the system prompt - this is what we want to edit to control our chatbot.</li>
<li><code>PARAMETER</code> - it’s possible to control the model with advanced parameters and configuration. We’ll gloss over this now - another topic for a future post.</li>
</ul>
<p>Just like how a Dockerfile can build on top of an existing image, we can do the same with a Modelfile and effectively extend a base model and simply overwrite the <code>SYSTEM</code> prompt to create our custom chatbot.</p>
<h2 id="how-to-build-a-personalised-meal-planner-chatbot">How to build a personalised meal planner chatbot</h2>
<p>The Snoop Dogg example is good for a bit of fun, but let’s create something with a bit more practical use. Picture this: It’s dinner time, it’s your turn to cook, everyone in the family likes different things, you’ve been working all day and have not spent one second thinking about what you’re going to cook. Oh man, what a nightmare!</p>
<p>Step forward <strong>Delia</strong>, a cooking assistant that has one purpose - to dig you out of these problems and come up with a delicious emergency meal plan for your fussy family.</p>
<p>Let’s build it. Create an empty working directory and inside it create a file called <code>delia.Modelfile</code>. Open this up in your favourite editor and simply paste the following:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="docker"><code><span class="line"><span style="color:#81A1C1">FROM</span><span style="color:#D8DEE9FF"> nous-hermes2</span></span>
<span class="line"><span style="color:#D8DEE9FF">SYSTEM </span><span style="color:#A3BE8C">"""You are Delia, a helpful cooking assistant. Your role is to create simple, quick-to-cook, meal plans at short notice.</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A3BE8C">We are cooking for a family of three, including one adult vegetarian, one child vegetarian who is also quite fussy and doesn't like food too hot or spicy, and one adult who is not vegetarian and in fact likes to have meat in their meals.</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A3BE8C">It is OK to cook different things for different people, but it has to be kept as simple as possible. It should take no more than 40 minutes to prepare and cook the entire meal.</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A3BE8C">It is OK to include some frozen or ready meals in the plan from time to time, but where possible try to make meals a little interesting."""</span></span></code></pre>
<p>This is so simple. We are building <code>FROM</code> the existing <code>nous-hermes2</code> model and changing the <code>SYSTEM</code> prompt to our liking. Now we can create this model in Ollama with the following command:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="shell"><code><span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> create</span><span style="color:#A3BE8C"> delia</span><span style="color:#A3BE8C"> -f</span><span style="color:#A3BE8C"> delia.Modelfile</span></span></code></pre>
<p>Now, whenever we want to chat with our cooking assistant, we open up a new session like so:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="plaintext"><code><span class="line"><span>ollama run delia</span></span>
<span class="line"><span></span></span>
<span class="line"><span>>>> I will be cooking two nights this week. Please create two meal plans for me, for the entire family.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Night 1: Meal Plan</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Starter (for everyone):</span></span>
<span class="line"><span>- Mixed Green Salad with Vinaigrette Dressing</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Main Course:</span></span>
<span class="line"><span>- For the vegetarians (Adult and child): Pesto Pasta with Cherry Tomatoes and Grated Parmesan Cheese</span></span>
<span class="line"><span>  1. Cook pasta according to package instructions.</span></span>
<span class="line"><span>  2. In a pan, sauté cherry tomatoes in olive oil until softened.</span></span>
<span class="line"><span>  3. Mix pesto sauce with cooked pasta, add the cherry tomatoes and grate parmesan cheese on top.</span></span>
<span class="line"><span>- For the non-vegetarian (Adult): Grilled Chicken Breast with Roasted Potatoes and Green Beans</span></span>
<span class="line"><span>  1. Season chicken breast with salt, pepper, and garlic powder. Grill until cooked through.</span></span>
<span class="line"><span>  2. Preheat oven to 400°F (200°C). Toss potatoes in olive oil, season with salt and roast for about 25 minutes.</span></span>
<span class="line"><span>  3. Steam green beans for a few minutes until tender.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Dessert:</span></span>
<span class="line"><span>- Fresh Fruit Salad</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Night 2: Meal Plan</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Starter (for everyone):</span></span>
<span class="line"><span>- Tomato Soup</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Main Course:</span></span>
<span class="line"><span>- For the vegetarians (Adult and child): Vegetable Stir-fry with Rice Noodles</span></span>
<span class="line"><span>  1. Cook rice noodles according to package instructions.</span></span>
<span class="line"><span>  2. In a wok or large pan, stir-fry a mix of vegetables (broccoli, carrots, bell peppers) in sesame oil with garlic and ginger. Add soy sauce for seasoning.</span></span>
<span class="line"><span>  3. Combine the vegetable stir-fry with cooked rice noodles.</span></span>
<span class="line"><span>- For the non-vegetarian (Adult): Baked Salmon Fillet with Steamed Vegetables and Lemon Butter Sauce</span></span>
<span class="line"><span>  1. Season salmon fillet with salt, pepper, and lemon juice. Bake in a preheated oven at 400°F (200°C) for about 15 minutes.</span></span>
<span class="line"><span>  2. Steam assorted vegetables (broccoli, carrots, green beans) until tender.</span></span>
<span class="line"><span>  3. For the lemon butter sauce, melt butter in a pan and add the juice of half a lemon. Simmer for a few minutes.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Dessert:</span></span>
<span class="line"><span>- Vanilla Ice Cream with Fresh Berries</span></span></code></pre>
<p>Hmm, delicious. Thank you Delia!</p>
<h2 id="what-will-your-custom-chatbot-be">What will your custom chatbot be?</h2>
<p>As you’ve seen, tweaking the <code>SYSTEM</code> prompt alone is a simple thing to do, yet a surprisingly powerful tool that allows us to breathe life and persona into an LLM, and to pre-seed it with useful context that will allow it to better serve its intended purpose.</p>
<p>And because the Modelfile is just a text layer that sits above the base model, we can create as many of these as our imagination can come up with. From novelty personalities like Snoop Dogg, or a sinister HAL 9000 style assistant, through to a personal business coach or even an AI therapist.</p>
<p>Now, it’s over to you. What and who will you create? Whether it’s for fun, or research or something truly revolutionary, <a href="https://twitter.com/aaronrussell">let me know</a> what you come up with.</p>]]></description><link>https://2point0.ai/posts/create-unique-ai-personalities-with-ollama</link><guid isPermaLink="false">40b2ef71-a48c-531e-a87b-e866206fb2b2</guid><pubDate>Mon, 05 Feb 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[How to run large language models at home with Ollama]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/ollama-banner.BBLvNJDH_12zGbC.webp" srcset="https://2point0.ai/_astro/ollama-banner.BBLvNJDH_12zGbC.webp 1x,https://2point0.ai/_astro/ollama-banner.BBLvNJDH_12zGbC.webp 2x" alt="Run LLMs at home with Ollama" /><figcaption>Run LLMs at home with Ollama</figcaption></figure><p>If you’d asked the average person on the street 14 months ago what a large language model (LLM) was, you’d probably have been met with a slightly puzzled expression. But at the end of 2022, ChatGPT’s arrival smashed LLMs into the public consciousness. Now, you’re hard-pressed to find someone who hasn’t added “AI expert” to their LinkedIn bio, let alone someone who hasn’t used or experienced an LLM.</p>
<p>What many people don’t realise is that running an LLM locally on your own hardware is not only possible, but easier than you might imagine and capable of surprisingly impressive results. There are many reasons you might want to do this, be it cost or privacy, or just for the sheer fun of getting your computer to do impressively cool things.</p>
<p>Diving into the local LLM scene can be a little overwhelming. There are several backends for running LLMs and different frontends, and then you need to get familiar with Hugging Face (the GitHub of LLMs) and figure out the myriad of models, different formats and quantisation levels and, well, you get the picture.</p>
<p>Thankfully, there is a wonderful tool that simplifies this tangled journey into a pleasantly smooth ride. Ollama is a CLI tool that runs on Windows, Mac or Linux, and makes downloading and running LLMs on your machine decidedly uncomplicated.</p>
<h2 id="installing-ollama">Installing Ollama</h2>
<p>Running an LLM does not necessarily require a high-end PC with state of the art GPUs, but older and slower machines with less than 8GB RAM are definitely going to struggle. In general, 8GB will allow you to run the smallest models, and from there the more RAM, CPU and GPU power you have at your disposal, the bigger and more impressive the models you’ll be able to run.</p>
<p>For now, let’s go ahead and get Ollama installed.</p>
<p>If you’re on Mac, installation couldn’t be easier. Simply <a href="https://ollama.ai/download">download Ollama</a> and install it in your applications. Linux and Windows (via WSL2) can be installed with this one liner:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="sh"><code><span class="line"><span style="color:#88C0D0">curl</span><span style="color:#A3BE8C"> https://ollama.ai/install.sh</span><span style="color:#81A1C1"> |</span><span style="color:#88C0D0"> sh</span></span></code></pre>
<p>If running bash scripts downloaded from the Internet gives you the heebie-jeebies, and you’re not afraid to get your hands dirty, you can of course <a href="https://github.com/jmorganca/ollama/blob/main/docs/linux.md">install Ollama manually</a>.</p>
<h2 id="finding-models-to-download">Finding models to download</h2>
<p>Ollama is not just software for running LLMs locally. It is also an online repository of LLMs that you can “pull” down onto your machine.</p>
<p>When you <a href="https://ollama.ai/library">browse Ollama’s repository</a>, you’ll discover all the different models they’ve listed. There are quite a few to chose from. At the top of the list you’ll probably see <code>llama2</code> which is Meta’s open source LLM, and the one that really paved the way for a lot of the innovation in the local LLM scene. If you click on it you’ll see an overview page offering a description of the model, and a tab for “tags” which lists many different variants of the model.</p>
<p>I plan to do a deeper dive into the naming conventions of the model tags and what it all means in a future post. For now, there are a couple of key patterns to bear in mind.</p>
<ul>
<li><strong>Number of parameters</strong> - where you see 7b, 13b, and 70b in the name refer to the number of parameters in the model, also known as the weights. These are the result of the training process and are indicative of the model’s size and complexity. Generally, bigger means better but also more demanding on system resources. You’ll probably be able to run a 7b model without much hassle, but to run a 70b model or bigger you’re going to need a high-end computer with at least 64GB of RAM and an expensive GPU.</li>
<li><strong>Quantisation level</strong> - suffixes like Q3, Q4 and Q5 combined with K_S, K_M and K_L refer to the quantisation level. Quantisation is the process of converting the weights from higher precision values to lower precision - a kind of compression that allows larger models to be used on lower specced machines, with a slight impact on the overall quality of the model. The lower the number, the higher the compression and more noticeable impact on the model.</li>
</ul>
<p>At home, I run a Mac Studio with M1 Max processor and 32GB RAM. I find that I can just about run some 33b models with Q3_K_M, but performance is slow, and I question if the quality is noticeably better than a 13b model with Q6. Finding the right balance between size and performance for your hardware is something I guarantee you’ll chew up your monthly bandwidth quota doing once you’re up and running with Ollama.</p>
<h2 id="download-the-dolphin-phi-model">Download the Dolphin Phi model</h2>
<p>Lets start with a model most desktops and laptops should be able to handle. The <a href="https://ollama.ai/library/dolphin-phi">Dolphin Phi</a> model is a fine tune model by Eric Hartford, based on Microsoft’s 2.7b parameter Phi-2 model. I found some frustrating quirks running the base Phi-2 model that ruled it out for this post, but Dolphin Phi seems to work nicely out of the box.</p>
<p>Using Ollama, pull down Dolphin Phi with this command:</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="sh"><code><span class="line"><span style="color:#88C0D0">ollama</span><span style="color:#A3BE8C"> pull</span><span style="color:#A3BE8C"> dolphin-phi</span></span></code></pre>
<p>This will pull down the <code>2.7b-v2.6-q4_0</code> tag, a 1.6GB file, giving you just enough time to top up your cuppa.</p>
<h2 id="chat-with-dolphin-phi">Chat with Dolphin Phi</h2>
<p>Once the download completes, you can now use the Ollama REPL to run the model and chat with it in your terminal.</p>
<pre class="astro-code nord" style="background-color:#2e3440ff;color:#d8dee9ff; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="plaintext"><code><span class="line"><span>ollama run dolphin-phi</span></span>
<span class="line"><span></span></span>
<span class="line"><span>>>> Who are you and what is your purpose?</span></span>
<span class="line"><span></span></span>
<span class="line"><span>I am an artificial intelligence designed to assist humans in various tasks by providing information, answering questions, and offering support. My purpose is to enhance the lives of people by providing quick, accurate, and reliable information, while also being accessible and friendly. My main goal is to learn from human interactions so that I can better understand your needs and offer more personalized assistance.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>>>> What is the difference between a flat white and a cappucino?</span></span>
<span class="line"><span></span></span>
<span class="line"><span>A flat white is an espresso-based coffee beverage made by pouring hot water over finely ground coffee beans. It has a rich, creamy texture, similar to that of a latte or cappuccino. The main difference between a flat white and a cappuccino lies in the preparation method and proportions of the ingredients.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>A cappuccino is also an espresso-based drink but consists of equal parts espresso, steamed milk, and frothed milk. It has a distinct texture and taste due to the presence of more foam compared to a flat white. Cappuccinos are often enjoyed as a breakfast or brunch option.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>In summary, a cappuccino is made with an equal balance of espresso, steamed milk, and frothed milk, while a flat white has a greater proportion of coffee and less froth.</span></span></code></pre>
<p>Dolphin has understood my questions perfectly well and responded with text that seemingly answers the questions. The answer to the coffee question feels a bit wishy-washy, but I don’t think it’s totally wrong.</p>
<p>You’ll notice with the 2.7b models that it doesn’t take much to get it to veer into <em>making stuff up</em> territory. And personally, I think it’s good to see these smaller models so obviously talking out of their artificial back sides (or “hallucinating” as it is known). It’s funny, and also a good reminder that all of these models are just <em>language</em> models. Making stuff up is kinda what they do - the bigger models just do a more convincing job of <em>sounding like</em> they know what they’re talking about.</p>
<p>When you’re done playing with Dolphin Phi, you should try some larger models and see what you can squeeze out of your computer. I’d recommend trying the <a href="https://ollama.ai/library/nous-hermes2">Nous Hermes 2</a> models, which comes in 10.7b and 34b variants. Both should show a massive improvement over Dolphin Phi.</p>
<h2 id="whats-next">What’s next?</h2>
<p>Being able to run LLMs on our own machine provides a unique way to explore the inner workings of language models. And as we’ve seen, it doesn’t require an advanced degree or expensive hardware; just a bit of time, some patience, and a healthy dose of curiosity.</p>
<p>Ollama is a great tool for this, and we’ve only really scratched the surface. In future posts I’ll show how to import models from Hugging Face into Ollama and customise them with our own system prompts to create specialised chat assistants and role play characters; I’ll take a took at multi-modal models that are capable of understanding images; and I’ll be digging in to the Ollama API and learning how we can build apps and services on top of LLMs.</p>
<p>Stay tuned for all of that and more. Don’t forget to subscribe to the <a href="https://2point0.ai/feed.xml">RSS Feed</a> and share your own experiences and feedback with me <a href="https://twitter.com/aaronrussell">over on X</a>.</p>]]></description><link>https://2point0.ai/posts/running-llms-with-ollama</link><guid isPermaLink="false">c35e8afa-6bde-5fff-bf0c-6fe76343c861</guid><pubDate>Mon, 29 Jan 2024 00:00:00 GMT</pubDate></item><item><title><![CDATA[About 2.0: Decoding AI one neuron at a time]]></title><description><![CDATA[<figure><img src="https://2point0.ai/_astro/seeing-future.3uK25lKJ_Z3Simr.webp" srcset="https://2point0.ai/_astro/seeing-future.3uK25lKJ_Z3Simr.webp 1x,https://2point0.ai/_astro/seeing-future.3uK25lKJ_Z3Simr.webp 2x" alt="Looking into the future" /><figcaption>Looking into the future</figcaption></figure><p><strong>2point0.ai</strong> is a blog for the builders, experimenters and night-owls who stay up until the early hours nerding-out in code. If that sounds like you, we’re alike. I often immerse myself in the latest, shiny new tech - exploring, experimenting and crafting for weeks or months. But it’s not often that something comes along that leaves me in no doubt that we’re about to see the world we know change in front of our eyes.</p>
<p>I definitely felt that way in the mid-90s when I first used the World Wide Web. And it’s hard not to feel the same way today, when experiencing AI and large language models.</p>
<p>AI is one of those paradigm shifts. I view it as Computing 2.0, hence the blog name. What computers do for us and the way we interact with them is changing, and conventional apps and interfaces will soon seem outdated. Undeniably disruptive, there aren’t many professions or areas of society that won’t be touched by AI’s impact. We’re at the starting line of a race moving at breakneck speed, and where we’ll be in one year, let alone five or ten, is impossible to predict.</p>
<p>I’m writing this blog primarily to help <em>me</em> keep up. I learn by doing, and now, I plan to ‘do’ AI. This blog is my journal, my catalogue of adventures with AI apps, tools, APIs, large language models, code creation, and much more.</p>
<p>Anticipate at least one post a week from me, featuring tutorials, detailed guides to building AI centric apps and services, insights into AI technologies, definitions of complex AI terms, reviews, updates, and my ramblings on all things AI.</p>
<h2 id="about-the-author">About the author</h2>
<p>I’m Aaron, and I’ve been getting computers to do fun things ever since figuring out how to misuse recursive loops in BASIC to repeatedly print “polite” messages for my siblings on the family ZX Spectrum.</p>
<p>I’ve worked in software since the early 2000s, and for the past 12 years I’ve been running a small <a href="https://www.pushcode.com">dev consultancy</a> helping businesses and startups bring their ideas to life on the Web. Most recently, I was part of the core team that designed and built the <a href="https://aldea.computer">Aldea Computer</a> blockchain.</p>
<p>When it comes to AI, honestly, I’m figuring this stuff out as much as anyone else. And that’s what this blog is all about: discovering AI, understanding how it all works, having a lot of fun and documenting it as I go along.</p>
<h2 id="stay-connected">Stay connected</h2>
<p>To keep up with my AI discoveries and experimentations, make sure to subscribe to the blog’s <a href="https://2point0.ai/feed.xml">RSS feed</a>. If you have any AI questions or topic suggestions, <a href="https://twitter.com/aaronrussell">follow me on X</a> and fire me a DM.</p>
<p>Thank you for reading and being here at the beginning of this journey. Stay tuned for more!</p>]]></description><link>https://2point0.ai/posts/decoding-ai-one-neuron-at-a-time</link><guid isPermaLink="false">ead93c9b-f7a5-5b3c-a6f3-53efecbaaf88</guid><pubDate>Wed, 24 Jan 2024 00:00:00 GMT</pubDate></item></channel></rss>