{"id":7515,"date":"2024-09-13T01:19:00","date_gmt":"2024-09-13T05:19:00","guid":{"rendered":"https:\/\/www.both.org\/?p=7515"},"modified":"2024-09-10T07:20:19","modified_gmt":"2024-09-10T11:20:19","slug":"working-with-ollama","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=7515","title":{"rendered":"Working with Ollama"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"7515\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>Now that I&#8217;m working with Ollama, I needed to figure out how to locate the models on my storage medium and determine the amount of space they were occupying. This is especially important for the MacBook Air, which has a 256 GB drive that is already half full. My Linux computer, on the other hand, has a terabyte NVME drive, so I&#8217;m not as worried about storage there. However, I still like to track where everything is and how much storage it uses. I wanted to compile a list of the downloaded models and learn how to delete them.<\/p>\n\n\n\n<p>After Ollama is installed, you can get a list of the commands available to you by entering the following command into the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ollama help<br><code><br>Usage:<br>  ollama &#91;flags]<br>  ollama &#91;command]<br><br>Available Commands:<br>  serve       Start ollama<br>  create      Create a model from a Modelfile<br>  show        Show information for a model<br>  run         Run a model<br>  pull        Pull a model from a registry<br>  push        Push a model to a registry<br>  list        List models<br>  ps          List running models<br>  cp          Copy a model<br>  rm          Remove a model<br>  help        Help about any command<br><br>Flags:<br>  -h, --help      help for ollama<br>  -v, --version   Show version information<\/code><\/code><\/pre>\n\n\n\n<p>Check the version of ollama you are using with: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ ollama -v <\/code>ollama version is 0.3.9<\/code><\/pre>\n\n\n\n<p>Downloading models is easy using &#8216;ollama pull&#8217;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ ollama pull gemma2<\/code><\/code><\/pre>\n\n\n\n<p>This downloads the model to your local computer. You can also initiate a pull request by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ ollama run phi3<\/code><\/code><\/pre>\n\n\n\n<p>This command sequence pulls the &#8216;phi3&#8217; model down to your computer. After I had tried a few models I wanted to get a sense of how much space they were taking on my system and I used the &#8216;list&#8217; or &#8216;ls&#8217; switch of the &#8216;ollama&#8217; command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ ollama list\nNAME            \tID          \tSIZE  \tMODIFIED     \nllama3.1:latest \tf66fc8dc39ea\t4.7 GB\t2 hours ago \t\ncodegemma:latest\t0c96700aaada\t5.0 GB\t43 hours ago\t\nphi3:latest     \t4f2222927938\t2.2 GB\t47 hours ago\t\ngemma2:latest   \tff02c3702f32\t5.4 GB\t3 days ago  \t\nphi3:medium     \tcf611a26b048\t7.9 GB\t3 days ago  \t\ngemma2:2b       \t8ccf136fdd52\t1.6 GB\t3 days ago  <\/code><\/code><\/pre>\n\n\n\n<p>Now I can see how much storage the models are using. It&#8217;s easy to delete a model. I decided to delete the oldest one first. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ ollama rm gemma2\ndeleted 'gemma2'<\/code><\/code><\/pre>\n\n\n\n<p>Just to be sure, I ran &#8216;ollama ls&#8217;; sure enough, the model was gone. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>NAME            \tID          \tSIZE  \tMODIFIED     \nllama3.1:latest \tf66fc8dc39ea\t4.7 GB\t2 hours ago \t\ncodegemma:latest\t0c96700aaada\t5.0 GB\t44 hours ago\t\nphi3:latest     \t4f2222927938\t2.2 GB\t47 hours ago\t\nphi3:medium <\/code><\/code><\/pre>\n\n\n\n<p>You can check on how many models are running on your machine with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ollama ps\nNAME       \tID          \tSIZE  \tPROCESSOR\tUNTIL              \nphi3:latest\t4f2222927938\t6.0 GB\t100% CPU \t4 minutes from now\t<\/code><\/pre>\n\n\n\n<p>Using the &#8216;show&#8217; command shows you information about the model. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ollama show phi3\n  Model                                 \n  \tarch            \tphi3  \t                \n  \tparameters      \t3.8B  \t                \n  \tquantization    \tQ4_0  \t                \n  \tcontext length  \t131072\t                \n  \tembedding length\t3072  \t                \n  \t                                      \n  Parameters                            \n  \tstop\t\"&lt;|end|>\"      \t                   \n  \tstop\t\"&lt;|user|>\"     \t                   \n  \tstop\t\"&lt;|assistant|>\"\t                   \n  \t                                      \n  License                               \n  \tMicrosoft.                          \t  \n  \tCopyright (c) Microsoft Corporation.<\/code><\/pre>\n\n\n\n<p>In conclusion, Ollama has revolutionized our understanding and interaction with AI. Stop a model from running by pressing <strong>CTRL +c<\/strong>. Exit the model by entering <strong>CTRL +d<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that I&rsquo;m working with Ollama, I needed to figure out how to locate the models on my<\/p>\n","protected":false},"author":32,"featured_media":6986,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[307,5],"tags":[560],"class_list":["post-7515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-linux","tag-ollama"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7515"}],"version-history":[{"count":3,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7515\/revisions"}],"predecessor-version":[{"id":7526,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7515\/revisions\/7526"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/6986"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}