Skip to content

A comprehensive web interface for experimenting with Ollama parameters and understanding how they affect model responses.

Notifications You must be signed in to change notification settings

takuphilchan/ollama_parameters_explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Ollama Parameter Explorer

A comprehensive web interface for experimenting with Ollama parameters and understanding how they affect model responses.

Features

  • Interactive Parameter Controls: Sliders and toggles for all major Ollama parameters
  • Real-time Parameter Adjustment: See parameter values change in real-time
  • Streaming Responses: Choose between streaming and non-streaming responses
  • Parameter Presets: Quick presets for Creative, Balanced, and Precise configurations
  • Model Management: Automatic detection of available Ollama models
  • Quick Test Prompts: Pre-made prompts to test different parameter effects
  • Modern UI: Clean, responsive interface with visual feedback

Parameters Explained

Core Parameters

  • Temperature (0.0-2.0): Controls randomness. Lower = more deterministic, higher = more creative
  • Top P (0.0-1.0): Nucleus sampling - limits token choices by cumulative probability
  • Top K (1-100): Limits to top K most likely tokens
  • Repeat Penalty (0.5-2.0): Penalizes repetitive text (1.0 = no penalty)

Advanced Parameters

  • Context Length: Number of tokens to keep in context window
  • Max Response Length: Maximum tokens to generate in response
  • Seed: For reproducible results (optional)

Mirostat (Advanced Sampling)

  • Mirostat: Alternative to temperature/top_p sampling
  • Mirostat Tau: Target entropy level
  • Mirostat Eta: Learning rate for entropy adjustment

Setup Instructions

Prerequisites

  1. Install Ollama:

    # On macOS
    brew install ollama
    
    # On Linux
    curl -fsSL https://ollama.ai/install.sh | sh
    
    # On Windows - download from https://ollama.ai
  2. Start Ollama service:

    ollama serve
  3. Pull at least one model:

    # Example models
    ollama pull llama2
    ollama pull codellama
    ollama pull mistral

Installation

  1. Clone or create project directory:

    mkdir ollama-parameter-explorer
    cd ollama-parameter-explorer
  2. Create the directory structure:

    mkdir templates
  3. Save the files:

    • Save the Flask backend code as app.py
    • Save the HTML template as templates/index.html
    • Save requirements as requirements.txt
  4. Install Python dependencies:

    pip install -r requirements.txt
  5. Run the application:

    python app.py
  6. Open your browser and go to: http://localhost:5000

Directory Structure

ollama-parameter-explorer/
├── app.py                 # Flask backend
├── requirements.txt       # Python dependencies
├── templates/
│   └── index.html        # Frontend template
└── README.md             # This file

Usage Guide

Getting Started

  1. Ensure Ollama is running (ollama serve)
  2. Start the Flask app (python app.py)
  3. Open http://localhost:5000 in your browser
  4. Select a model from the dropdown
  5. Adjust parameters using the sliders and toggles
  6. Enter a message and click send

Parameter Experimentation Tips

Understanding Temperature Through Examples

  • Temperature 0.1: "The capital of France is Paris." (same answer every time)
  • Temperature 1.5: "The capital of France is Paris, that magnificent city of lights and romance!" (varied, creative responses)
  • Try asking "What is 2+2?" at different temperatures to see how it affects even simple questions

Understanding Top P and Top K

  • High Top P (0.9) + Low Top K (10): Contradictory - gives inconsistent results
  • Low Top P (0.5) + High Top K (50): Also contradictory - Top P will override Top K
  • Best practice: Use either Top P OR Top K, not both at extreme values
  • Try disabling one (set Top K to 100 or Top P to 1.0) to see the other's pure effect

Testing Repeat Penalty

  • Ask for a story without repeat penalty (1.0) - notice natural repetition
  • Set repeat penalty to 1.5+ - see how the AI awkwardly avoids repeating words
  • Sweet spot is usually 1.1-1.3 for most use cases

Using Presets Effectively

  • Creative: Perfect for "Write a story about..." prompts
  • Balanced: Great for general questions and conversations
  • Precise: Use for "Explain how..." or "What is..." questions

Troubleshooting

"Cannot connect to Ollama"

  • Check if Ollama is running: ps aux | grep ollama
  • Start Ollama: ollama serve
  • Verify port 11434 is accessible

"No models available"

  • Pull at least one model: ollama pull llama2
  • Check available models: ollama list

Slow responses

  • Reduce context length
  • Reduce max response length
  • Try a smaller model

Connection status always shows "error"

  • Check if port 11434 is blocked by firewall
  • Verify Ollama is running on localhost:11434
  • Try restarting Ollama service

API Endpoints

  • GET /api/models - Get available Ollama models
  • POST /api/chat - Send chat request with parameters
  • GET /api/health - Check Ollama connection status

Browser Compatibility

  • Modern browsers with ES6+ support
  • Chrome, Firefox, Safari, Edge
  • Mobile responsive design

Contributing

Feel free to submit issues and enhancement requests!

About

A comprehensive web interface for experimenting with Ollama parameters and understanding how they affect model responses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published