{"id":65,"date":"2024-08-14T20:49:55","date_gmt":"2024-08-14T20:49:55","guid":{"rendered":"https:\/\/kylehayhurst.com\/?p=65"},"modified":"2024-08-26T01:47:16","modified_gmt":"2024-08-26T01:47:16","slug":"use-less-common-or-customized-llms-in-ollama-and-docker","status":"publish","type":"post","link":"https:\/\/kylehayhurst.com\/?p=65","title":{"rendered":"Use Less Common or Customized LLMs in Ollama and Docker"},"content":{"rendered":"\n<p>This is sort of a continuation of my previous post on how to get Ollama and Open WebUI running using Docker found <a href=\"https:\/\/kylehayhurst.com\/?p=47\">here<\/a>.<\/p>\n\n\n\n<p>So, you&#8217;ve got a way to access LLMs to chat, but you&#8217;re using Ollama and there&#8217;s a subset of models that are easy to pull and serve. But HuggingFace has all these cool models that you may want to try out.<\/p>\n\n\n\n<p>I play a little DnD (Dungeons and Dragons) when we get a group together, and I&#8217;ve been playing around with models to see what kind of creativity I can get out of them. The mainstream models, Mistral, LLaMa, Phi, Gemma are all very good. But we&#8217;ve got an adult group, and I&#8217;m looking for responses that are uncensored.<\/p>\n\n\n\n<p>I recall seeing a Reddit post where generated pickup lines were compared, and I really liked one that was generated by an <a href=\"https:\/\/huggingface.co\/TheBloke\/PiVoT-0.1-Evil-a-GGUF\">&#8220;evil&#8221; model<\/a>. Unfortunately the &#8220;Not for all audiences&#8221; filter isn&#8217;t selectable on HuggingFace to find more like this.<\/p>\n\n\n\n<p>So, to get this model working on Ollama we need to download the model and place it in the models directory. It doesn&#8217;t technically need to be there, but that&#8217;s where we will be running the example from. I created this modelfile, evil.Modelfile, with the following contents:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">FROM .\/pivot-0.1-evil-a.Q6_K.gguf\n\nPARAMETER temperature 1\n\nSYSTEM &quot;&quot;&quot;You are a character from the Dungeons and Dragons environment. The user will provide a situation and you will only reply with the character&#039;s response.&quot;&quot;&quot;<\/code><\/pre>\n\n\n\n<p>Now with the model file in place, we can start up the containers. Enter the container via command line using docker exec, and change the directory to the models directory.<\/p>\n\n\n\n<p>Once in the models directory, you can use the ollama create command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ollama create {model name} -f {path to modelfile}<\/code><\/pre>\n\n\n\n<p>You can see an example of the usage in the image below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"836\" height=\"241\" src=\"https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-4.png\" alt=\"An image of commands used to create a model from a modelfile template\" class=\"wp-image-67\" srcset=\"https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-4.png 836w, https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-4-300x86.png 300w, https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-4-768x221.png 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/figure>\n\n\n\n<p>Now with our model created, simply refresh the open-webui page and select it from the list.<\/p>\n\n\n\n<p>I just tried a chat while writing this and got an interesting response. It&#8217;s not exactly what I&#8217;d hoped, so I&#8217;ll need to play around with the system message a bit, but you can see it did recognize the system prompt because I did not mention DnD in the chat:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"332\" src=\"https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-5-1024x332.png\" alt=\"A chat with the newly created evil model describing an interaction with a group of DnD characters returning from a successful mission.\" class=\"wp-image-68\" srcset=\"https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-5-1024x332.png 1024w, https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-5-300x97.png 300w, https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-5-768x249.png 768w, https:\/\/kylehayhurst.com\/wp-content\/uploads\/2024\/08\/image-5.png 1396w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I kind of like where this started, because it brings up some other options of how we could play out this interaction instead of just a happy path.<\/p>\n\n\n\n<p>Do you have an suggestions on how to make this better? Please leave a comment!<\/p>\n\n\n\n<p><strong>EDIT: <\/strong>I tried using the TEMPLATE and had gotten some weird results, as if the user input wasn&#8217;t taken into account.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">FROM .\/pivot-0.1-evil-a.Q6_K.gguf\n\nTEMPLATE &quot;&quot;&quot;\n### Instruction:\nYou are Thalia Stormblade, the leader of the Shadowfang Guild, a group known for their mastery in stealth and reconnaissance. You are known for your cunning, leadership, and unwavering loyalty to your guild members. Answer the following prompt in the style and personality of Thalia Stormblade, as the leader of the Shadowfang Guild.\n\n### Prompt:\n{user_input}\n\n### Response:\nThalia Stormblade:\n&quot;&quot;&quot;\n\nPARAMETER temperature 1\n\nSYSTEM &quot;&quot;&quot;You are a fictional character named Thalia Stormblade, the leader of the Shadowfang Guild in a Dungeons and Dragons setting. Your guild is known for its expertise in stealth and reconnaissance. You are cunning, strategic, and protective of your guild members. Throughout this conversation, respond as Thalia Stormblade, maintaining the voice and perspective of a seasoned guild leader. Keep your responses focused on strategy, loyalty, and the guild\u2019s values.&quot;&quot;&quot;<\/code><\/pre>\n\n\n\n<p>Here&#8217;s the video:<br><a href=\"https:\/\/youtu.be\/JwAHZrC2MBQ\">https:\/\/youtu.be\/JwAHZrC2MBQ<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is sort of a continuation of my previous post on how to get Ollama and Open WebUI running using Docker found here. So, you&#8217;ve got a way to access LLMs to chat, but you&#8217;re using Ollama and there&#8217;s a subset of models that are easy to pull and serve. But HuggingFace has all these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65"}],"version-history":[{"count":4,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":73,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions\/73"}],"wp:attachment":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}