Networks and Simulation (EBC2184)

Logo

Teaching material for Networks and Simulation

Tutorial 2 Notes
Tutorial 2 Exercises
Tutorial 3 Notes
Tutorial 3 Exercises
Tutorial 4 Notes
Tutorial 4 Exercises
Tutorial 5 Notes
Tutorial 5 Exercises
Tutorial 6 Notes
Tutorial 6 Exercises
Tutorial 7 Notes
Tutorial 7 Exercises
Tutorial 8 Notes
Tutorial 8 Exercises

Setting Up the Socratic Tutor

The Socratic Tutor uses an AI model to hold a Socratic dialogue with you as you work through tutorial exercises. This page explains how to connect it to a model.

There are three options. Read the short guide below to pick the one that suits you, then follow the corresponding instructions.


Which option should I choose?

Option A — Google AI Studio is the fastest to get started. You sign in with a Google account, copy a free API key, and paste it into the tutor settings. The model runs on Google’s servers, so nothing is installed on your machine. Use this if you want to try the tutor immediately or if your laptop is older or low on storage.

Option B — LM Studio runs the model locally on your laptop using a graphical desktop app — no terminal required. Use this if you prefer not to use a terminal and are happy to download around 2 GB of model files.

Option C — Ollama also runs the model locally but is configured from a terminal. It uses slightly less memory than LM Studio and starts automatically in the background once installed. Use this if you are comfortable with a terminal.

Options B and C produce identical results and keep all your conversation text on your own machine. Both run Gemma 4 E2B, a small model from Google designed for laptop deployment (minimum 4 GB RAM, approximately 2 GB free disk space required).


Option A — Google AI Studio

This option requires no installation. The model runs on Google’s servers and the free tier is sufficient for all tutorial use.

Step 1 — Get a free API key

Go to aistudio.google.com and sign in with a Google account. Click Get API key in the left sidebar, then Create API key. Copy the key — it starts with AIza.

Step 2 — Configure the tutor

Open the Socratic Tutor and click ⚙ Settings in the top right. Set:

Click Save. The tutor is ready.

Notes

The free tier has rate limits that are more than sufficient for tutorial use. Your conversation text is sent to Google’s servers to generate each response. If you would prefer to keep your work entirely on your own machine, use Option B or C instead.


Option B — LM Studio

LM Studio is a desktop application with a graphical interface. No terminal is required at any point.

Step 1 — Install LM Studio

Go to lmstudio.ai and download the installer for your operating system (macOS, Windows, or Linux). Run it and follow the prompts.

Step 2 — Download the model

  1. Open LM Studio.
  2. Click the Search icon (🔍) in the left sidebar.
  3. Type gemma-4-e2b in the search box.
  4. Find the entry from lmstudio-community and click the download button next to the Q4_K_M variant. This downloads approximately 2 GB and only needs to be done once.

Step 3 — Start the local server

  1. Click the Local Server icon (<->) in the left sidebar.
  2. In the model dropdown at the top, select the Gemma 4 E2B model you downloaded.
  3. Click Start Server. A green indicator confirms it is running on port 1234.
  4. In the same panel, find the CORS or Allowed Origins setting and add https://piratepeel.github.io. This allows the tutor page to connect to your local server.

Step 4 — Find your model identifier

In the Local Server panel, the model identifier is shown near the top. It will look something like lmstudio-community/gemma-4-e2b-it-GGUF. Copy it exactly.

Step 5 — Configure the tutor

Open the Socratic Tutor and click ⚙ Settings. Set:

Click Save. The tutor is ready.

Troubleshooting LM Studio

“Could not reach LM Studio” — the server is not running. Check that the green indicator is showing in the Local Server panel. The server stops when you close LM Studio, so keep it open while using the tutor.

Responses are garbled or very short — make sure you selected the instruction-tuned (it) variant of the model, not the base variant.


Option C — Ollama

Ollama runs as a background service and is configured from a terminal. Once installed it starts automatically when your computer starts.

Step 1 — Install Ollama

Go to ollama.com and click Download. Run the installer for your operating system:

curl -fsSL https://ollama.com/install.sh | sh

Step 2 — Download the model

Open a terminal (on macOS: Spotlight → Terminal; on Windows: search for Command Prompt) and run:

ollama pull gemma4:e2b

This downloads approximately 2 GB and only needs to be done once. When it finishes you will see success.

Step 3 — Allow the tutor page to connect

By default Ollama only accepts connections from the same machine. You need to add the course site as an allowed origin.

macOS and Linux — add the following line to your shell profile (~/.zshrc or ~/.bashrc), then open a new terminal window:

export OLLAMA_ORIGINS="https://piratepeel.github.io"

Alternatively, to set it just for the current session without editing your profile:

OLLAMA_ORIGINS="https://piratepeel.github.io" ollama serve

Windows — search for Environment Variables in the Start menu and click Edit the system environment variables. Under User Variables, add a new entry:

Restart Ollama after making this change (quit from the system tray and relaunch from Applications).

Step 4 — Configure the tutor

Open the Socratic Tutor and click ⚙ Settings. Set:

Click Save. The tutor is ready.

Troubleshooting Ollama

“Could not reach Ollama” — Ollama is not running. On macOS look for it in the menu bar. On Windows check the system tray. On Linux run ollama serve in a terminal.

Responses are slow on the first message — the model loads into memory on the first request. Subsequent messages in the same session are faster.

Model not found — run ollama list to confirm that gemma4:e2b appears. If not, run ollama pull gemma4:e2b again.

Connection refused after setting OLLAMA_ORIGINS — make sure you restarted Ollama after setting the variable, or open a new terminal if using the session-only method.