Setting up Llama.py

Step 1) Install Python 3.

Step 2) Install the requests library:

“pip install requests”

Step 3) In the terminal, request:

“ollama pull gemma3:4b”

Step 4) Open Notepad or another text editor (VS Code, etc.) and paste the prompt to the right.

Save a file named run_llama.py.

Step 5) Open Terminal (Mac) or Command Prompt / PowerShell (Windows). Go to the folder where you saved the file, and run:

“python run_llama.py

Prompt

import time
import requests

MODEL = "gemma3:4b"

prompt = input("Enter your prompt:\n")

t0 = time.perf_counter()
r = requests.post(
"
http://localhost:11434/api/generate",
json={
"model": MODEL,
"prompt": prompt,
"stream": False,
"options": {
"num_predict": 1024} }, )

t1 = time.perf_counter()

print("runtime_sec:", t1 - t0)

data = r.json()

# Token
print("prompt_eval_count:", data.get("prompt_eval_count"))
print("eval_count:", data.get("eval_count"))

# Time in nanoseconds
print("total_duration:", data.get("total_duration"))
print("prompt_eval_duration:", data.get("prompt_eval_duration"))
print("eval_duration:", data.get("eval_duration"))

print("\n--- Full response -\n")
print(data.get("response", ""))

Running Llama.py

  1. Copy your prompt from your doc.

  2. Paste it into the script when it asks for input.

  3. Press Enter.

  4. Copy and save these outputs into your data table:

  • runtime_sec

  • prompt_eval_count

  • eval_count

  • mark correct/incorrect separately after checking the answer key (MMS-12)

* Use the same laptop and same model tag for all trials. Close extra apps if possible.

Example Response

“response_len_chars: 272

prompt_eval_count: 61

eval_count: 160

total_duration: 22336796400

prompt_eval_duration: 1919932400

eval_duration: 19537118600

--- Full response ---

Explanation:

We use the product rule: d/dx [u(x)v(x)] = u'(x)v(x) + u(x)v'(x).

Let u(x) = x³ and v(x) = e^(2x). Then u'(x) = 3x² and v'(x) = 2e^(2x).

Therefore, f'(x) = 3x²e^(2x) + x³(2e^(2x)) = 3x²e^(2x) + 2x³e^(2x).

Final Answer: f'(x) = 3x²e^(2x) + 2x³e^(2x)”

Data Collection

  • Total_duration: Run time (sec)

  • Response_len_chars: Token_in

  • Prompt_eval_count: Token_out

  • Based on the explanation and the MMS-12, identify if your answer is correct.

  • Add a short summary or a list of helpful resources here.