VKVlad KulikovPublic / lectures
RL for LLM1 / 13

Module 1. Introduction: Reinforcement Learning for LLMs

Try each exercise first. Expand worked answers or project guidance when needed; their open state is shared between RU/EN.

Download course files (.zip) 382.1 KB

The archive preserves the source folder structure, both languages, and supporting files.

Agent, environment, state, action, and reward

Consider two episodes.

  • In a corridor, an agent occupies a cell, chooses left or right, and receives +1+1 for reaching the right terminal.
  • A language model sees a prompt and the generated prefix, selects the next token, and a verifier scores the completed response.

Match each object to the concept.

ObjectConcept
A. A cell index or the pair “prompt + prefix”1. Policy
B. A rule for choosing a direction or a next-token distribution2. Environment
C. One concrete move or one concrete token3. State
D. Corridor dynamics, or external tools and generation constraints4. Reward
E. +1+1 for a terminal, or the final response score5. Action

Write the answer as A-?, B-?, C-?, D-?, E-?.

Show answer and solution

Answer: A-3, B-1, C-5, D-2, E-4.

  • A state describes the current situation: a cell, or a prompt plus prefix.
  • A policy specifies the choice rule: a direction rule or a token distribution.
  • An action is one choice that was actually taken.
  • The environment determines transitions and external consequences.
  • A reward is scalar feedback after a transition or episode.

The key boundary is between a policy and an action: a distribution is not the same object as one sample from it.

A policy is not the selected action

Choose the single most accurate statement.

  1. πθ(a∣s)\pi_\theta(a\mid s) is the action already selected, while aa is the probability of that action.

  2. πθ(⋅∣s)\pi_\theta(\cdot\mid s) is a distribution over actions, aa is one selection from it, and reward evaluates a consequence.

  3. Policy and reward are two names for the same scalar function.

  4. A stochastic policy must assign equal probability to every action.

Show answer and solution

Answer: 2.

πθ(⋅∣s)\pi_\theta(\cdot\mid s) denotes the full probability distribution over available actions. A concrete aa is selected from that distribution. Reward then evaluates a consequence; it is neither the action nor its probability.

Option 4 is false because stochastic does not mean uniform. A policy may assign probabilities 0.90.9 and 0.10.1 to two actions.

The exact sense in which an LLM is a policy

For the token-level abstraction, match notation to meaning.

NotationMeaning
A. sts_t1. Transformer weights
B. ata_t2. Prompt plus the generated prefix
C. πθ(⋅∣st)\pi_\theta(\cdot\mid s_t)3. The next selected token
D. θ\theta4. The full next-token probability distribution

Write the answer as A-?, B-?, C-?, D-?.

Then explain in one sentence why this exact correspondence does not imply that every pretrained LLM was trained with RL.

Show answer and solution

Answer: A-2, B-3, C-4, D-1.

In the token-level formulation,

st=(x,y<t),at=yt,πθ(⋅∣st)=softmax⁡(zθ(st)).s_t=(x,y_{<t}), \qquad a_t=y_t, \qquad \pi_\theta(\cdot\mid s_t)=\operatorname{softmax}(z_\theta(s_t)).

This is an exact correspondence at the level of the mathematical action-selection model. It does not determine how the weights θ\theta were obtained: next-token pretraining, supervised learning, and RL can all produce a model that defines a token distribution.

Reward and return

Choose two correct statements. Here, return is the accumulated discounted sum of future rewards.

  1. Reward rt+1r_{t+1} belongs to one transition, while GtG_t aggregates future rewards from time tt onward.

  2. Return is always equal to the final reward of an episode.

  3. When γ=0\gamma=0, return GtG_t includes only the immediate reward rt+1r_{t+1}.

  4. When γ=1\gamma=1, every finite episode has the same return.

Show answer and solution

Answers: 1 and 3.

Reward rt+1r_{t+1} is local to one transition. Return

Gt=rt+1+γrt+2+γ2rt+3+⋯G_t=r_{t+1}+\gamma r_{t+2}+\gamma^2r_{t+3}+\cdots

aggregates future rewards. When γ=0\gamma=0, only the immediate term rt+1r_{t+1} remains.

Option 2 is true only in special tasks with a single nonzero terminal reward and γ=1\gamma=1. Option 4 is false: when γ=1\gamma=1, return is the ordinary sum of rewards, and different episodes can have different sums.

What creates the feedback loop in online RL

Choose the single most accurate statement.

  1. RL does not use gradient descent.

  2. RL never uses demonstrations or labeled data.

  3. During online collection, the policy affects the distribution of the next experience, while reward usually does not reveal the outcomes of all actions that were not selected.

  4. Every scalar loss is a reward, so every optimization problem is RL.

Show answer and solution

Answer: 3.

During online collection, the current policy participates in creating the next dataset. After an update, action frequencies, visited states, and observed outcomes change. Reward normally reports the result of the selected action or trajectory, not a full set of counterfactual outcomes for every alternative.

The other options are false: RL can use gradient descent and demonstrations, and scalar-valued loss alone does not create a decision-making problem.

Separate stages of an LLM pipeline

The four names below are:

  • supervised fine-tuning (SFT), learning from demonstrations;
  • direct preference optimization (DPO);
  • reinforcement learning from human feedback (RLHF), implemented here with proximal policy optimization (PPO); below, PPO-RLHF;
  • Best-of-N selection.

Match each operation to its description.

OperationDescription
A. SFT1. Generate candidates, select the best one, and leave parameters unchanged
B. DPO on fixed pairs2. Score fresh rollouts with a reward model, then update the policy and critic
C. PPO-RLHF3. Maximize demonstration likelihood
D. Best-of-N4. Optimize a pairwise loss relative to a reference policy

Write the answer as A-?, B-?, C-?, D-?.

Show answer and solution

Answer: A-3, B-4, C-2, D-1.

  • Supervised fine-tuning (SFT) maximizes demonstration likelihood.
  • Direct preference optimization (DPO) uses fixed pairs and a pairwise loss relative to a reference policy.
  • Reinforcement learning from human feedback (RLHF), implemented here with proximal policy optimization (PPO), collects rollouts and updates the policy; a typical PPO-RLHF system also uses a reward model and critic.
  • Best-of-N selects a candidate at inference time and does not by itself change parameters.

Choose the abstraction level

For each task, select the most natural primary model.

  1. One prompt, one complete response, and one terminal reward-model score; the derivation does not inspect token-level credit assignment.

  2. The derivation needs log⁡πθ(y∣x)=∑tlog⁡πθ(yt∣x,y<t)\log\pi_\theta(y\mid x)=\sum_t\log\pi_\theta(y_t\mid x,y_{<t}) and token-level Kullback–Leibler divergence.

  3. An agent calls a browser, the website state is only partly observed, and calls have different durations.

Options:

  • contextual bandit;
  • finite token-level Markov decision process (MDP);
  • agentic partially observable Markov decision process (POMDP) or semi-Markov decision process (semi-MDP).
Show answer and solution
  1. Contextual bandit. The complete response is collapsed into one action followed by one terminal reward.

  2. Finite token-level Markov decision process (MDP). The state is the full prefix and the action is the next token.

  3. Partially observable Markov decision process (POMDP) or semi-Markov decision process (semi-MDP). External state is hidden and macro-actions can have unequal duration.

No abstraction is permanently “the true one.” The appropriate choice depends on which mechanism must be explicit in a particular derivation.

Why DPO is not simply classical offline RL

Choose two correct statements.

  1. DPO uses fixed preference pairs and is therefore offline in the ordinary engineering sense.

  2. DPO necessarily trains a value function through Bellman backups.

  3. A typical DPO problem does not contain transition tuples and extrapolation error in the same form as classical offline RL.

  4. DPO is performed only at inference time and does not update parameters.

Show answer and solution

Answers: 1 and 3.

DPO uses fixed data, so offline is appropriate as an engineering description of data access. A typical DPO problem, however, is not built from transitions (s,a,r,s′)(s,a,r,s'), does not perform Bellman backups, and does not reproduce the classical value-extrapolation problem in the same form as offline RL.

A concise accurate description is: DPO is direct offline preference optimization derived from a Kullback–Leibler-regularized human-feedback formulation.

What near/on-policy means for proximal policy optimization

Choose the single most accurate description of proximal policy optimization (PPO).

  1. Every sample is used exactly once.

  2. A policy snapshot generates a batch, which may then be reused for several minibatch epochs while a surrogate objective uses clipped probability ratios without a hard bound on the actual ratios; acceptable policy lag is part of the protocol.

  3. Data may be arbitrarily stale because clipping completely removes off-policy bias.

  4. On-policy means only that no replay buffer exists.

Show answer and solution

Answer: 2.

In PPO, a snapshot πold\pi_{\text{old}} usually generates the rollouts. One batch may then be processed for several minibatch epochs. The ratio

rt(θ)=πθ(at∣st)πold(at∣st)r_t(\theta)= \frac{\pi_\theta(a_t\mid s_t)}{\pi_{\text{old}}(a_t\mid s_t)}

enters a clipped surrogate objective. Clipping removes the incentive for some further ratio changes but does not enforce a hard bound on actual ratios or KL. This is a near/on-policy protocol, not a promise that every sample is used once. Clipping reduces the risk of an excessively large step, but it does not turn arbitrarily stale data into strictly on-policy data.

Verifiable rewards and group-relative optimization: regime versus algorithm

The two terms are:

  • reinforcement learning with verifiable rewards (RLVR);
  • group relative policy optimization (GRPO).

Choose the single correct statement.

  1. RLVR is a particular clipping formula, while GRPO is a dataset type.

  2. RLVR describes a regime in which reward can be checked automatically; GRPO is an algorithm family for updating the policy and may use that reward.

  3. By definition, GRPO has no baseline.

  4. Every RLVR experiment must use canonical GRPO.

Show answer and solution

Answer: 2.

Reinforcement learning with verifiable rewards (RLVR) describes the source of feedback: correctness can be checked by code, tests, an exact-answer rule, or another automatic procedure.

Group relative policy optimization (GRPO) describes a way to form relative advantages from a group of rollouts and update the policy. GRPO is often used in RLVR, but the terms are not identical: one reward regime allows multiple algorithms, and GRPO can consume other scalar feedback.

Find the component with no policy training

A system generates 32 responses from a frozen LLM, scores them with a rule-based verifier, and returns the best one. What operation is this?

  1. PPO

  2. GRPO

  3. Best-of-N / inference-time selection

  4. Offline RL

In one additional sentence, explain what must change for a training loop to appear.

Show answer and solution

Answer: 3 — Best-of-N / inference-time selection.

The model parameters are frozen, so the system performs candidate search and selection rather than policy training. A training loop appears when the scores or selected responses are used to change θ\theta, for example through a supervised update, preference optimization, or a policy-gradient update on collected rollouts.

Two boundaries: temperature softmax and Kullback–Leibler divergence

Choose two correct statements.

  1. For a fixed finite logit vector and pure softmax, entropy is non-decreasing in temperature TT.

  2. This automatically proves entropy monotonicity for every combination of top-pp, top-kk, penalties, and hidden transformations in an application programming interface (API).

  3. Kullback–Leibler divergence (KL) can limit drift from a reference policy, but it does not itself validate the reward model or proxy objective.

  4. Small KL divergence guarantees high true reward.

Show answer and solution

Answers: 1 and 3.

For a pure temperature policy with fixed logits,

πi(T)∝ezi/T,dHdT=Var⁡πT(z)T3≥0.\pi_i(T)\propto e^{z_i/T}, \qquad \frac{dH}{dT}= \frac{\operatorname{Var}_{\pi_T}(z)}{T^3}\ge 0.

This statement does not automatically extend to a complete decoding pipeline with top-pp, top-kk, penalties, or hidden transformations.

Kullback–Leibler divergence (KL) measures distributional change relative to a reference policy. It can constrain drift, but it does not prove that the reward model measures the intended property or that a proxy objective matches the true objective.

Return

For rewards [1,0,0,10][1,0,0,10] and γ=0.9\gamma=0.9, compute G0G_0.

Show answer and solution
G0=1+0.9⋅0+0.92⋅0+0.93⋅10=1+7.29=8.29.\begin{aligned} G_0 &=1+0.9\cdot0+0.9^2\cdot0+0.9^3\cdot10\\ &=1+7.29\\ &=8.29. \end{aligned}

A backward-recursion check gives

G3=10,G2=9,G1=8.1,G0=8.29.G_3=10, \quad G_2=9, \quad G_1=8.1, \quad G_0=8.29.

Where the parameter enters the trajectory distribution

For a finite MDP,

pθ(τ)=ρ0(s0)∏t=0T−1πθ(at∣st)P(st+1∣st,at)PR(rt+1∣st,at,st+1).p_\theta(\tau) = \rho_0(s_0) \prod_{t=0}^{T-1} \pi_\theta(a_t\mid s_t) P(s_{t+1}\mid s_t,a_t) P_R(r_{t+1}\mid s_t,a_t,s_{t+1}).

Identify which factor depends on θ\theta in a standard model-free formulation, explain why an update changes the distribution of subsequently collected trajectories, and state what is assumed about PP and PRP_R.

Show answer and solution

In a standard model-free formulation, the factors that depend on θ\theta are

πθ(at∣st).\pi_\theta(a_t\mid s_t).

The initial distribution ρ0\rho_0, environment dynamics PP, and reward rule PRP_R are treated as fixed with respect to the policy parameters. Updating θ\theta changes action probabilities, which changes subsequent transitions, visited states, and therefore the entire distribution pθ(τ)p_\theta(\tau). If the environment or reward model is updated at the same time, its parameters must be written separately; that is a broader nonstationary system.

For an LLM, the same statement means that an updated model generates a different response distribution; in an agentic system, different actions can also lead to different external states.

Exact corridor baseline

For the symmetric corridor in the main text:

  • start at s=2s=2;
  • terminal states are 00 and 44;
  • the random policy chooses left or right with probability 1/21/2;
  • reward is 11 only upon reaching 44;
  • the cutoff is 20 actions.

What is the exact value of V20π(2)V_{20}^{\pi}(2)? Give a fraction or a decimal.

Show answer and solution

Over two steps from the center, four equally likely outcomes exist:

  • left, left — absorption at 0;
  • right, right — absorption at 4;
  • left, right and right, left — return to 2.

The probability of surviving one two-step block is 1/21/2. Avoiding both terminals for 20 actions requires surviving ten blocks:

P(timeout)=(12)10=11024.P(\text{timeout})= \left(\frac12\right)^{10} = \frac1{1024}.

By symmetry, the probabilities of terminating on the left and right are equal. Hence

V20π(2)=1−P(timeout)2=1−1/10242=10232048=0.49951171875.V_{20}^{\pi}(2) = \frac{1-P(\text{timeout})}{2} = \frac{1-1/1024}{2} = \frac{1023}{2048} = 0.49951171875.

The value 0.50.5 belongs to the version without a time limit. It is useful intuition but not the exact baseline for the executed protocol.

Probability of a complete response

Suppose a completed three-token response has conditional probabilities

0.5,0.2,0.1.0.5,\qquad 0.2,\qquad 0.1.
  1. Compute πθ(y∣x)\pi_\theta(y\mid x).

  2. Compute the natural logarithm of the response probability.

  3. Show that it equals the sum of the three token log-probabilities.

  4. In one sentence, explain why one final reward creates a credit-assignment problem across these tokens.

Show answer and solution

The autoregressive probability of the complete response is the product of the conditional probabilities:

πθ(y∣x)=0.5⋅0.2⋅0.1=0.01.\pi_\theta(y\mid x) =0.5\cdot0.2\cdot0.1 =0.01.

Its natural logarithm is

ln⁡0.01≈−4.605170.\ln0.01 \approx -4.605170.

Separately,

ln⁡0.5+ln⁡0.2+ln⁡0.1≈−0.693147−1.609438−2.302585=−4.605170.\ln0.5+\ln0.2+\ln0.1 \approx -0.693147-1.609438-2.302585 = -4.605170.

Therefore,

log⁡πθ(y∣x)=∑tlog⁡πθ(yt∣x,y<t).\log\pi_\theta(y\mid x) = \sum_t\log\pi_\theta(y_t\mid x,y_{<t}).

One final reward evaluates the whole response but does not identify which of the three token choices was useful or harmful. That is the credit-assignment problem.

Discounted return

Implement:

Python
def discounted_return(rewards: list[float], gamma: float) -> float:
    """Return G_0 for a non-empty finite reward sequence."""
    ...

Requirements:

  • 0≤γ≤10\le\gamma\le1;
  • rewards is a non-empty, finite, one-dimensional sequence;
  • use the backward recurrence Gt=rt+1+γGt+1G_t=r_{t+1}+\gamma G_{t+1};
  • invalid input must raise ValueError.

Open checks:

Python
assert abs(discounted_return([1, 0, 0, 10], 0.9) - 8.29) < 1e-12
assert discounted_return([1, 1, 1], 1.0) == 3.0
assert discounted_return([5, 100], 0.0) == 5.0

Hidden checks include negative rewards, a one-element sequence, length 1000, nan, an empty list, and γ\gamma outside [0,1][0,1].

Show answer and solution
Python
from __future__ import annotations

import math
import numpy as np


def discounted_return(rewards: list[float], gamma: float) -> float:
    values = np.asarray(rewards, dtype=np.float64)
    if values.ndim != 1 or values.size == 0:
        raise ValueError("rewards must be a non-empty 1D sequence")
    if not np.isfinite(values).all():
        raise ValueError("rewards must be finite")
    if not math.isfinite(gamma) or not 0.0 <= gamma <= 1.0:
        raise ValueError("gamma must lie in [0, 1]")

    result = 0.0
    for reward in values[::-1]:
        result = float(reward) + gamma * result
    return float(result)

The backward recurrence avoids explicitly computing powers and makes one pass: O(T)O(T) time and O(1)O(1) additional memory.

Numerically stable temperature softmax

Implement:

Python
def softmax_with_temperature(
    logits: np.ndarray,
    temperature: float,
) -> np.ndarray:
    ...

Requirements:

  • input is a non-empty, finite, one-dimensional array;
  • temperature is finite and strictly positive;
  • computation remains stable for logits around 1000;
  • output is finite, non-negative, and sums to 1;
  • adding one constant to every logit leaves the answer unchanged.

Open checks:

Python
p = softmax_with_temperature(np.array([2.0, 1.0, 0.0]), 1.0)
assert np.isfinite(p).all()
assert abs(float(p.sum()) - 1.0) < 1e-14

q = softmax_with_temperature(np.array([1002.0, 1001.0, 1000.0]), 1.0)
assert np.allclose(p, q, atol=2e-14, rtol=0)
Show answer and solution
Python
import math
import numpy as np


def softmax_with_temperature(
    logits: np.ndarray,
    temperature: float,
) -> np.ndarray:
    z = np.asarray(logits, dtype=np.float64)
    if z.ndim != 1 or z.size == 0:
        raise ValueError("logits must be a non-empty 1D array")
    if not np.isfinite(z).all():
        raise ValueError("logits must be finite")
    if not math.isfinite(temperature) or temperature <= 0.0:
        raise ValueError("temperature must be finite and positive")

    scaled = z / temperature
    scaled -= scaled.max()
    weights = np.exp(scaled)
    return weights / weights.sum()

Subtracting the maximum uses softmax shift invariance and prevents overflow. The common multiplicative factor cancels between numerator and denominator, so probabilities are unchanged.

Policy entropy and the temperature curve

Implement:

Python
def categorical_entropy(probabilities: np.ndarray) -> float:
    ...


def policy_entropy(logits: np.ndarray, temperature: float) -> float:
    ...

Requirements:

  • entropy is measured in nats;
  • zero probabilities use the convention 0ln⁡0=00\ln0=0;
  • negative probabilities and sums different from 1 are rejected;
  • for logits=[2,1,0,-1], values from the main-text grid are reproduced within 10−610^{-6};
  • on np.geomspace(0.1, 10, 100), entropy is non-decreasing up to numerical tolerance 10−1210^{-12}.

Optional output: save temperature_entropy_student.png and state in the caption that monotonicity applies to pure softmax.

Open checks:

Python
p = softmax_with_temperature(np.array([2.0, 1.0, 0.0]), 1.0)
assert abs(categorical_entropy(p) - 0.8323956) < 1e-6
assert abs(categorical_entropy([0.25, 0.25, 0.25, 0.25]) - np.log(4)) < 1e-12
assert abs(categorical_entropy([1.0, 0.0, 0.0])) < 1e-12
Show answer and solution
Python
import math
import numpy as np

def softmax_with_temperature(logits: np.ndarray, temperature: float) -> np.ndarray:
    z = np.asarray(logits, dtype=np.float64)
    if z.ndim != 1 or z.size == 0 or not np.isfinite(z).all():
        raise ValueError("logits must be a non-empty finite 1D array")
    if not math.isfinite(temperature) or temperature <= 0.0:
        raise ValueError("temperature must be finite and positive")
    scaled = z / temperature
    shifted = scaled - np.max(scaled)
    weights = np.exp(shifted)
    return weights / weights.sum()


def categorical_entropy(probabilities: np.ndarray) -> float:
    p = np.asarray(probabilities, dtype=np.float64)
    if p.ndim != 1 or p.size == 0 or not np.isfinite(p).all():
        raise ValueError("probabilities must be a non-empty finite 1D array")
    if np.any(p < 0.0):
        raise ValueError("probabilities must be non-negative")
    if not math.isclose(float(p.sum()), 1.0, rel_tol=1e-10, abs_tol=1e-12):
        raise ValueError("probabilities must sum to 1")

    positive = p > 0.0
    return float(-np.sum(p[positive] * np.log(p[positive])))


def policy_entropy(logits: np.ndarray, temperature: float) -> float:
    return categorical_entropy(softmax_with_temperature(logits, temperature))

To reproduce the table:

Python
logits = np.array([2.0, 1.0, 0.0, -1.0])
for temperature in [0.25, 0.5, 1.0, 2.0, 4.0, 10.0]:
    print(temperature, f"{policy_entropy(logits, temperature):.6f}")

The output is 0.093113, 0.455429, 0.947537, 1.245050, 1.348243, 1.380071.

Monte Carlo evaluation of the corridor

Implement:

Python
def run_corridor_episode(
    rng: np.random.Generator,
    *,
    max_steps: int = 20,
) -> float:
    ...


def estimate_corridor_value(
    n_episodes: int,
    *,
    seed: int = 7,
    max_steps: int = 20,
) -> float:
    ...

Protocol:

  • states 0,1,2,3,4, starting at 2;
  • action 0 means left, action 1 means right;
  • rng.integers(0, 2) selects the action;
  • terminal 0 returns 0.0, terminal 4 returns 1.0;
  • timeout returns 0.0;
  • create exactly one np.random.default_rng(seed) for the whole experiment.

Open checks:

Python
assert abs(estimate_corridor_value(1000, seed=7, max_steps=20) - 0.494) < 1e-15

estimate = estimate_corridor_value(20_000, seed=23, max_steps=20)
assert abs(estimate - 0.49951171875) < 0.02

Explain why comparison with 0.5 is useful intuition, while the exact baseline for this run is 1023/2048.

Show answer and solution
Python
import numpy as np


def run_corridor_episode(
    rng: np.random.Generator,
    *,
    max_steps: int = 20,
) -> float:
    if not isinstance(max_steps, int) or isinstance(max_steps, bool) or max_steps <= 0:
        raise ValueError("max_steps must be a positive integer")

    state = 2
    for _ in range(max_steps):
        action = int(rng.integers(0, 2))
        state += -1 if action == 0 else 1
        if state == 0:
            return 0.0
        if state == 4:
            return 1.0
    return 0.0


def estimate_corridor_value(
    n_episodes: int,
    *,
    seed: int = 7,
    max_steps: int = 20,
) -> float:
    if not isinstance(n_episodes, int) or isinstance(n_episodes, bool) or n_episodes <= 0:
        raise ValueError("n_episodes must be a positive integer")

    rng = np.random.default_rng(seed)
    returns = [run_corridor_episode(rng, max_steps=max_steps) for _ in range(n_episodes)]
    return float(np.mean(returns))

Verified values:

text
N=1000,  seed=7,  max_steps=20 -> 0.494
N=20000, seed=23, max_steps=20 -> 0.4933
exact finite-horizon value       -> 0.49951171875

Without a step limit, corridor symmetry gives probability 0.5 for the right terminal. With a 20-step limit, some trajectories reach neither boundary and receive reward 0.0. To survive each pair of steps, the process must return from state 1 or 3 to state 2, which happens with probability 1/2. The probability of remaining nonterminal through ten such pairs is therefore 2−10=1/10242^{-10}=1/1024. Symmetry splits the remaining probability equally between the left and right terminals, so the exact probability of the right terminal is

1−2−102=10232048=0.49951171875.\frac{1-2^{-10}}{2}=\frac{1023}{2048}=0.49951171875.

A random estimate need not match the exact value in every run. It should behave according to Bernoulli variance, with typical error decreasing approximately as 1/N1/\sqrt{N}.