<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Machine-Learning - Ollama | Derek Armstrong — Software Engineer · AI · Infrastructure</title><link>https://derekarmstrong.dev/tags/machine-learning---ollama/</link><atom:link href="https://derekarmstrong.dev/tags/machine-learning---ollama/index.xml" rel="self" type="application/rss+xml"/><description>Machine-Learning - Ollama</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Tue, 23 Apr 2024 00:00:00 +0000</lastBuildDate><image><url>https://derekarmstrong.dev/media/sharing.png</url><title>Machine-Learning - Ollama</title><link>https://derekarmstrong.dev/tags/machine-learning---ollama/</link></image><item><title>Run your own AI LLM in two commands</title><link>https://derekarmstrong.dev/blog/run-your-own-ai-llm-in-two-commands/</link><pubDate>Tue, 23 Apr 2024 00:00:00 +0000</pubDate><guid>https://derekarmstrong.dev/blog/run-your-own-ai-llm-in-two-commands/</guid><description>&lt;p&gt;&lt;strong&gt;Run Your Own AI Chatbot Locally with Meta&amp;rsquo;s Llama Model&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Ever wanted to have your own AI chatbot running locally? With Meta&amp;rsquo;s Llama model and Docker, you can set it up in just a few steps. Here’s how:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; Ensure Docker is installed on your machine. If you need to install Docker, follow the straightforward guide available at the Docker Docs.&lt;/p&gt;
&lt;blockquote class="border-l-4 border-neutral-300 dark:border-neutral-600 pl-4 italic text-neutral-600 dark:text-neutral-400 my-6"&gt;
&lt;p&gt;Install Docker Engine | Docker Docs&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Set Up the Docker Container&lt;/strong&gt; Open your terminal and execute the following command to create and run the Ollama container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This command downloads the Ollama image and runs it as a detached container, mapping the necessary ports and volumes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Access the Chatbot Interface&lt;/strong&gt; Once the container is active, use this command to access the shell, load your preferred Llama model, and initiate the chatbot interface:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; -it ollama ollama run llama2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can choose between &lt;code&gt;llama2&lt;/code&gt; or &lt;code&gt;llama3&lt;/code&gt; based on the model you wish to deploy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Congratulations!&lt;/strong&gt; You now have a locally running AI chatbot.&lt;/p&gt;
&lt;p&gt;![](
align=&amp;ldquo;center&amp;rdquo;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Further Exploration:&lt;/strong&gt; Dive into the Ollama documentation to discover how to use the API and experiment with other LLM models for your projects.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reference Documentation:&lt;/strong&gt; For more detailed information, refer to the Ollama Docker Image on Docker Hub.&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;h2 id="key-takeaways"&gt;Key Takeaways&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Running LLMs locally is now simple: one Docker command to spin up Ollama, a second to run it — no compute cluster needed&lt;/li&gt;
&lt;li&gt;Ollama defaults to 4096 tokens for most models; the model name alone runs with 4096 and doesn&amp;rsquo;t need explicit setting&lt;/li&gt;
&lt;li&gt;Swap models by running &lt;code&gt;docker exec -it ollama ollama run {modelname}&lt;/code&gt; — the same container serves any model Ollama supports&lt;/li&gt;
&lt;li&gt;Access the Ollama API at &lt;code&gt;http://localhost:11434&lt;/code&gt; for programmatic model interaction, or browse the full model library at
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="next"&gt;Next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
— why Ollama became insufficient for multi-user concurrency, and what replaced it&lt;/li&gt;
&lt;li&gt;
— why Docker matters for local development and infrastructure&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>