Monday, 31 March 2025

How to Use the ollama rm Command to Delete a Model?

The ollama rm command is used to delete a model from your Ollama environment. This is helpful when you no longer need a model or want to clean up your system by removing unused models.

How to Delete a Model?

To delete a model, simply use the following command:

ollama rm llama3.2

 

In this example, llama3.2 is the model I want to remove. You can replace it with the name or ID of the model you wish to delete.

 

Command Help:

For additional details on how to use the rm command, you can run:

ollama rm --help

$ollama rm --help
Remove a model

Usage:
  ollama rm MODEL [MODEL...] [flags]

Flags:
  -h, --help   help for rm

Environment Variables:
      OLLAMA_HOST                IP Address for the ollama server (default 127.0.0.1:11434)

With the ollama rm command, removing a model is quick and easy, ensuring that you can keep your system organized. Be cautious while using this command, as it permanently deletes the specified models!


Previous                                                    Next                                                    Home

How to List All Models Using Ollama?

How to List All Models Using Ollama?

The command ollama list is your go-to solution!

 

What Does ollama list Do?

The ollama list command provides a comprehensive list of all the models installed in your Ollama setup. This includes details about each model, such as its name, version, and any other metadata.

$ollama list
NAME               ID              SIZE      MODIFIED     
llama3.2:latest    a80c4f17acd5    2.0 GB    20 hours ago   

 

Explanation Of the Output

NAME: This column lists the name and tag of each model. In the example above, llama3.2:latest refers to a model named llama3.2 with the tag latest. The tag allows you to specify versions or different configurations of the same model.

 

ID: The ID column contains a unique identifier (UUID) for the model. In this case, a80c4f17acd5 is the identifier for the llama3.2:latest model. You can use this ID in various Ollama commands to target specific models.

 

SIZE: The size of the model is displayed in this column. Here, 2.0 GB indicates that the llama3.2:latest model takes up 2.0 gigabytes of disk space.

 

MODIFIED: This column shows the last time the model was modified. In the example above, the model was modified 20 hours ago. This helps you understand how recently the model was updated or modified.

 

Previous                                                    Next                                                    Home

ollama help: get information about any Ollama command

The ollama help command is your go-to tool for getting information about any Ollama command. If you're new to Ollama or unsure about how to use a specific command, ollama help provides a simple and structured guide to assist you.

$ollama help
Large language model runner

Usage:
  ollama [flags]
  ollama [command]

Available Commands:
  serve       Start ollama
  create      Create a model from a Modelfile
  show        Show information for a model
  run         Run a model
  stop        Stop a running model
  pull        Pull a model from a registry
  push        Push a model to a registry
  list        List models
  ps          List running models
  cp          Copy a model
  rm          Remove a model
  help        Help about any command

Flags:
  -h, --help      help for ollama
  -v, --version   Show version information

Use "ollama [command] --help" for more information about a command.

Get Help on Specific Commands:

To get more detailed help on a specific command, you can run:

ollama [command] --help

 For example, if you're curious about the run command, you'd run:


ollama run --help

 

This will provide additional information about how to use the run command, its options, and usage examples.

 

With the ollama help command, navigating Ollama and discovering all the available functionalities becomes simple and intuitive!

$ollama run --help
Run a model

Usage:
  ollama run MODEL [PROMPT] [flags]

Flags:
      --format string      Response format (e.g. json)
  -h, --help               help for run
      --insecure           Use an insecure registry
      --keepalive string   Duration to keep a model loaded (e.g. 5m)
      --nowordwrap         Don't wrap words to the next line automatically
      --verbose            Show timings for response

Environment Variables:
      OLLAMA_HOST                IP Address for the ollama server (default 127.0.0.1:11434)
      OLLAMA_NOHISTORY           Do not preserve readline history

 

Previous                                                    Next                                                    Home

Mastering Basic Commands in the Ollama Shell: A Quick Guide

When working with the Ollama shell, knowing the essential commands can make your experience seamless and efficient. Whether you're exploring model details, clearing sessions, or seeking guidance, these basic commands will help you navigate with ease. Here's a breakdown:

 

1. Get Help: /?, /help

If you're unsure about available commands or need guidance, simply type:

>>> /?
Available Commands:
  /set            Set session variables
  /show           Show model information
  /load <model>   Load a session or model
  /save <model>   Save your current session
  /clear          Clear session context
  /bye            Exit
  /?, /help       Help for a command
  /? shortcuts    Help for keyboard shortcuts

Use """ to begin a multi-line message.

>>> /help
Available Commands:
  /set            Set session variables
  /show           Show model information
  /load <model>   Load a session or model
  /save <model>   Save your current session
  /clear          Clear session context
  /bye            Exit
  /?, /help       Help for a command
  /? shortcuts    Help for keyboard shortcuts

Use """ to begin a multi-line message.

This will display a list of available commands and their purposes. It’s a quick way to find your footing.

 

2. Show Model Information: /show

The /show command is a powerful way to explore details about the current model you're working with.

>>> /show
Available Commands:
  /show info         Show details for this model
  /show license      Show model license
  /show modelfile    Show Modelfile for this model
  /show parameters   Show parameters for this model
  /show system       Show system message
  /show template     Show prompt template

 

To view the model's architecture and details, run: /show info

>>> /show info
  Model
    architecture        llama     
    parameters          3.2B      
    context length      131072    
    embedding length    3072      
    quantization        Q4_K_M    

  Parameters
    stop    "<|start_header_id|>"    
    stop    "<|end_header_id|>"      
    stop    "<|eot_id|>"             

  License
    LLAMA 3.2 COMMUNITY LICENSE AGREEMENT                 
    Llama 3.2 Version Release Date: September 25, 2024 

 

The output of /show info command is divided into 3 sections.

 

Section 1. Model Details

This section provides key technical specifications of the model:

 

architecture: The architecture of the model is llama, indicating that it is based on the LLaMA (Large Language Model Meta AI) framework, designed for handling large-scale language modeling tasks.

 

parameters: The model contains 3.2 billion parameters (3.2B). Parameters are the core components of the model that it learns during training. A higher number of parameters often indicates greater complexity and capability.

 

context length: The model can process input sequences of up to 131072 tokens in length. This determines how much text the model can consider at once while generating a response or making predictions.

 

embedding length: The embedding size is 3072, which indicates the dimensionality of the vector representations used for input tokens. Larger embeddings allow the model to encode richer information about the data.

 

quantization: The model uses a quantization technique called Q4_K_M, which reduces the size of the model by representing parameters with lower precision. This improves efficiency while maintaining performance, making it suitable for running on limited hardware resources.

 

Section 2: Parameters

This section lists the stopping tokens for the model, which signal the model when to end its output generation. These are predefined markers:

 

"<|start_header_id|>"
"<|end_header_id|>"
"<|eot_id|>"

When these tokens are encountered, the model knows to terminate the output generation or transition tasks. These tokens ensure outputs are concise and contextually appropriate.

 

Section 3: License

LLAMA 3.2 COMMUNITY LICENSE AGREEMENT:

Indicates the license under which this model is distributed. Licensing dictates how you can use the model, whether it's for personal, academic, or commercial purposes.

 

Version Release Date: September 25, 2024:

The version of the model you’re using was released on this date, ensuring you're aware of the latest updates or improvements.

 

3. Clear Session Context: /clear

Want to start fresh? Use the /clear command to reset the session context. It’s particularly useful when switching tasks or models.

 

Why These Commands Matter?

1.   Efficiency: These commands streamline your workflow by providing immediate access to model information.

2.   Clarity: They help you understand the model's capabilities and limitations.

3.   Convenience: Simplified session management ensures a smooth user experience.

 

Master these basic commands, and you’ll unlock the full potential of the Ollama shell in no time!

 

Previous                                                    Next                                                    Home

Exploring KAPLAY Components: The Building Blocks for Dynamic Game Objects

 

When creating a game, it’s important to have objects that can move, look interesting, and interact with each other. In KAPLAY, components are like building blocks that help you create these game objects. These components control how objects behave in the game, like where they are, how they move, and what they look like.

 

Here are some important components in KAPLAY:

·       pos(x, y): This sets the position of an object on the screen. You can choose where you want the object to appear in the game by giving it x and y coordinates.

·       sprite(): If you want your object to have a picture or animation, you can use the sprite() component. It lets you show images and create animations to make the object look more interesting.

·       area(): This component helps with collision detection, which is when objects in the game touch each other. Using the onCollide() method, you can make something happen when objects collide, like making a character bounce off an obstacle or lose points.

·       text(): Sometimes, you need to show text on the screen, like a score or a message. The text() component lets you display text on your game objects, so players can see important information.

·       scale(): This lets you resize your game objects. You can make objects bigger or smaller, or stretch them, depending on what you need for the game.

·       rect(width, height): With this component, you can draw a rectangle in the game. This is useful for things like creating walls, platforms, or buttons.

·       color(r, g, b): If you want to change the color of an object, you can use this component. You can set the color by using red, green, and blue (RGB) values.

 

KAPLAY has many components that help you make your game objects come to life. You can use them to decide how your objects look, move, and interact with other things in the game. By combining these components, you can create different kinds of objects that respond to what happens in the game, making your game more fun and interactive.

 

Follow below step-by-step procedure to build an Application to understand the components better.

 

Step 1: Create a KAPLAY project components by executing below command.

 

npx create-kaplay components

 

Upon successful execution of above command, you can see a project structure looks like below.

 

Step 2: Update src/main.js file with below content.

 

main.js

import kaplay from "kaplay";

// Constants for window dimensions
const WINDOW_WIDTH = 1000;
const WINDOW_HEIGHT = 1000;

// Utility object for generating random values
const Random = {
  /**
   * Generates a random integer between min and max (inclusive).
   * @param {number} min - The minimum value (inclusive).
   * @param {number} max - The maximum value (inclusive).
   * @returns {number} A random integer between min and max.
   */
  getInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  },

  // Get a random X-coordinate within the window
  getX() {
    return this.getInt(0, WINDOW_WIDTH);
  },

  // Get a random Y-coordinate within the window
  getY() {
    return this.getInt(0, WINDOW_HEIGHT);
  },

  // Get a random color code (0-255 for RGB)
  getColorCode() {
    return this.getInt(0, 255);
  },
};

// Initialize the KAPLAY game with specified dimensions
const k = kaplay({
  width: WINDOW_WIDTH,
  height: WINDOW_HEIGHT,
});

// Set global gravity for the game
k.setGravity(200);

// Load game assets
k.loadRoot("./"); // Sets the root directory for assets (useful for publishing)
k.loadSprite("bean", "sprites/bean.png"); // Load the "bean" sprite

/**
 * Spawns a new player object at a random X position.
 */
function spawnPlayer() {
  const player = add([
    k.pos(Random.getX(), Random.getInt(-50, 50)), // Start slightly above the screen
    k.sprite("bean"), // Use the "bean" sprite
    k.body(), // Adds physics body
    k.area(), // Enables collision detection
    k.color(
      // Assign a random color
      Random.getColorCode(),
      Random.getColorCode(),
      Random.getColorCode()
    ),
  ]);

  // Define movement controls for the player
  onKeyDown("left", () => player.move(-200, 0)); // Move left
  onKeyDown("right", () => player.move(200, 0)); // Move right
  onKeyDown("up", () => player.move(0, -200)); // Move up
  onKeyDown("down", () => player.move(0, 200)); // Move down
  onKeyDown("space", () => player.jump(400)); // Jump
}

// Create 10 players at random intervals
for (let i = 0; i < 10; i++) {
  k.loop(1, spawnPlayer); // Call spawnPlayer every second
}

Step 3: Execute below commands from the project root folder to run the Application.

 

npm install
npm run dev

 

Open the url ‘http://localhost:3001/’ in browser to see the Application.

You can see the demo recording here (https://www.youtube.com/shorts/89rHgQkTetM).

 

You can download the Application from this link.


In short, KAPLAY components make it easier to build and control game objects. They allow you to set positions, add images, detect collisions, resize objects, show text, and more—all with simple tools that help you create an exciting game.

 


Previous                                                    Next                                                    Home

Game Objects in KAPLAY

 

In KAPLAY, game objects are the core components that represent all entities in the game. They can be anything within the game world: the player, obstacles, background elements, or even interactive items like buttons or moving objects. These game objects serve as actors within the game, meaning they perform actions, interact with other objects, and contribute to the game’s functionality.

 

Key Features of Game Objects

·       Actors: Game objects act as actors that have the ability to perform actions like moving, rotating, or reacting to player inputs.

·       Components: Each game object is composed of components that define its behavior. For example, a game object could have a Sprite component to handle its visuals, a Position component to define its location in the game world, and a Physics component to handle movement or collisions.

·       Interaction: These objects interact with one another, meaning the player can collide with obstacles, items can be picked up, and enemies might chase or attack the player.

·       Behavior: The behavior of each game object is defined by the components that are attached to it. These components define how the object behaves in the game (e.g., movement, appearance, interactions).

 

Game Object Creation

Game objects are created using the add() function, which takes an array of components that define the object's behavior. Components are like building blocks for game objects, and they allow you to customize the behavior of each actor.

 

Follow below step-by-step procedure to build an application.

 

Step 1: Create a KAPLAY project game-obejcts by executing below command.

 

npx create-kaplay game-obejcts

 

Upon successful execution of above command, you can see a project structure looks like below.

 

Step 2: Update src/main.js file with below content.

 

main.js

import kaplay from "kaplay";

const gameWindowWidth = 1000;
const gameWindowHeight = 800;

// Utility object for random number generation
const Random = {
  /**
   * Generates a random integer between min and max (inclusive).
   * @param {number} min - The minimum value (inclusive).
   * @param {number} max - The maximum value (inclusive).
   * @returns {number} A random integer between min and max.
   */
  getInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  },

  /**
   * Generates a random x-coordinate within the game window's width.
   * @returns {number} A random x-coordinate.
   */
  getRandomX() {
    return this.getInt(100, gameWindowWidth);
  },

  /**
   * Generates a random y-coordinate within the game window's height.
   * @returns {number} A random y-coordinate.
   */
  getRandomY() {
    return this.getInt(100, gameWindowHeight);
  },

  /**
   * Generates a random color value (between 1 and 255).
   * @returns {number} A random color value.
   */
  getColor() {
    return this.getInt(1, 255);
  },

  /**
   * Generates a random movement vector for objects.
   * @returns {Object} A vector with x and y components.
   */
  getVector() {
    return { x: this.getInt(-1, 1), y: 0 }; // Random movement vector (x)
  },

  /**
   * Generates a random speed for movement between 50 and 500.
   * @returns {number} A random movement speed.
   */
  getMovementSpeed() {
    return this.getInt(50, 500);
  },
};

// Adds a rectangle shape with random properties
function addRectangle(k) {
  const width = Random.getInt(10, 40);
  const height = Random.getInt(10, 40);

  k.add([
    k.rect(width, height),
    k.pos(Random.getRandomX(), Random.getRandomY()),
    k.area(),
    k.body(),
    k.outline(3),
    k.move(
      k.vec2(Random.getVector().x, Random.getVector().y),
      Random.getMovementSpeed()
    ),
    k.color(Random.getColor(), Random.getColor(), Random.getColor()),
  ]);
}

// Adds a circle shape with random properties
function addCircle(k) {
  const radius = Random.getInt(10, 20);

  k.add([
    k.circle(radius),
    k.pos(Random.getRandomX(), Random.getRandomY()),
    k.area(),
    k.body(),
    k.outline(3),
    k.move(
      k.vec2(Random.getVector().x, Random.getVector().y),
      Random.getMovementSpeed()
    ),
    k.color(Random.getColor(), Random.getColor(), Random.getColor()),
  ]);
}

// Adds a sprite (player) with random starting position
function addSprite(k) {
  k.add([
    k.pos(Random.getRandomX(), Random.getRandomY()),
    k.sprite("bean"),
    k.body(),
    k.area(),
  ]);
}

// Initialize the Kaplay game engine
const k = kaplay({
  width: 1000,
  height: 800,
  background: [135, 206, 250], // Sky blue background
});

k.setGravity(100);

// Load the sprite
k.loadSprite("bean", "sprites/bean.png");

// Add on-screen instructions for the player
k.add([
  k.text("Welcome to the Kaplay Game!", { size: 48, color: [255, 255, 255] }), // White text with font size 48
  k.pos(100, 10), // Position text at the top-left corner
  k.color(0, 0, 0), // Black text color
]);

// Add game objects (rectangles, circles, sprites)
for (let i = 0; i < 50; i++) {
  addRectangle(k);
  addCircle(k);
  addSprite(k);
}

  Step 3: Execute below commands from the project root folder to run the Application.

npm install
npm run dev

 

Open the url ‘http://localhost:3001/’ in browser, you can see the Application that generates 50 rectangles, squares and sprite beans.

 

You can see the Application Demo here (https://www.youtube.com/watch?v=dKpTkvNgmds).

 

You can download the Application from this link.

Previous                                                    Next                                                    Home