Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Run Custom and Popular Open-Source LLMs Locally with Ollama

Tech 1

Ollama is an open-source, lightweight framework optimized for quickly building and running state-of-the-art open-source large language models (LLMs) locally, including Llama 3, Mistral, Gemma, and regionally fine-tuned variants like Llama 2 Chinese. Its official model library hosts a vast selection of pre-trained and specialized models, all with straightforward, cross-platfomr deployment.

Ollama supports Windows, macOS, and Linux, ensuring accessibility across most development and personal environments. Its compatible with a wide range of LLMs, such as Doubao, Llama 3, and Phi 3. Users can launch and interact with models using concise CLI commands, customize model behavior (e.g., creativity parameters, system prompts) via Modelfile configuration files, and run models with up to billions of parameters without cloud dependency.

  1. Installation: Download the appropriate installer for macOS, the Windows Preview build, or use the provided shell script for Linux systems.
  2. Launch a Prebuilt Model: Use the ollama run command with your desired model name to start an interactive session. For example, to run Llama 3:
    ollama run llama3
    
  3. Customize and Run a Model: Create a Modelfile in your working directory, start with a FROM directive to import a base model, and add custom settings. Then execute ollama create to build a new model instance and ollama run to launch it.
  4. List and Manage Models: View all installed models locally with:
    ollama list
    
  5. Pull Models in Advance: To download a model without immediately running it, use:
    ollama pull llama3
    
  6. API-based Interaction: For programmatic access, send HTTP POST requests to the local API endpoint (default: http://localhost:11434/api/chat). Here’s an example query about sky blue using cURL:
    curl http://localhost:11434/api/chat -d '{
      "model": "llama3",
      "messages": [
        { "role": "user", "content": "Why does the sky appear blue?" }
      ]
    }'
    

Web-based UI tools like Open WebUI can also be paired with Ollama for a graphical interface.

Tags: ollama

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.