essay-model / README.md
D0zy's picture
Add held-out benchmark (base vs LoRA vs constant) + fix usage snippet
befe537 verified
|
Raw History Blame Contribute Delete
12.2 kB
metadata
base_model: LiquidAI/LFM3-1.7B
library_name: peft
license: other
license_name: lfm1.0
license_link: LICENSE
datasets:
  - chillies/IELTS-writing-task-2-evaluation
language:
  - en
pipeline_tag: text-generation
tags:
  - lora
  - peft
  - ielts
  - essay-scoring
  - automated-essay-scoring
  - education
metrics:
  - mae
  - cohen_kappa
model-index:
  - name: essay-model
    results:
      - task:
          type: text-generation
          name: IELTS Writing Task 2 overall band scoring
        dataset:
          name: >-
            IELTS Writing Task 2 Evaluation, held-out essays never used in
            training (n=1000)
          type: chillies/IELTS-writing-task-2-evaluation
          split: train
        metrics:
          - type: mae
            value: 1.003
            name: MAE in bands (greedy decoding)
          - type: cohen_kappa
            value: 0.486
            name: Quadratic weighted kappa (greedy decoding)
          - type: mae
            value: 0.936
            name: MAE in bands (expected-value scoring)
          - type: cohen_kappa
            value: 0.465
            name: Quadratic weighted kappa (expected-value scoring)

essay-model

This model is a modified (fine-tuned) version of [LiquidAI/LFM3-1.7B] by Liquid AI. It is a LoRA fine-tune of LiquidAI/LFM3-1.7B that acts as an IELTS Writing Task 2 examiner: given the task question and an essay, it outputs an overall band score followed by feedback on Task Response, Coherence & Cohesion, Lexical Resource and Grammatical Range & Accuracy.

Training

  • Data: chillies/IELTS-writing-task-2-evaluation (~7,000 train examples, max 2048 tokens; loss only on the evaluation part)
  • Method: LoRA (r=16, alpha=32, dropout=0.05, all linear layers), 1 epoch, lr 2e-4, cosine schedule, effective batch size 8
  • Final validation loss: ~0.418 (on 100 essays from the dataset's test split, which overlaps the training data; see Evaluation)

Evaluation

Summary: on 1,000 essays it never saw in training, the adapter's overall band is off by about one band on average (MAE 1.00, QWK 0.49 with normal greedy generation). That is clearly better than the untuned base model (MAE 1.36, QWK 0.12) and than always answering 6.0 (MAE 1.16), but well short of examiner-level agreement, and its scores are compressed toward the middle of the scale.

Held-out essays (n = 1,000, never seen in training). 95% bootstrap confidence intervals in parentheses.

Scoring MAE ↓ RMSE ↓ Exact ↑ Within ±0.5 ↑ Within ±1.0 ↑ QWK ↑ Pearson r ↑ Mean error
Always answer 6.0 (training median) 1.16 (1.11–1.21) 1.39 10.7% 33.1% 59.1% 0.00 – −0.14
LFM3-1.7B base, zero-shot (same prompt) 1.36 (1.30–1.43) 1.68 12.0% 33.1% 52.7% 0.12 (0.09–0.15) 0.23 +0.98
essay-model, greedy (default generation) 1.00 (0.95–1.06) 1.30 19.4% 46.9% 65.3% 0.49 (0.43–0.54) 0.49 −0.01
essay-model, expected-value scoring (see Usage) 0.94 (0.89–0.98) 1.15 15.8% 42.9% 71.3% 0.46 (0.42–0.51) 0.55 0.00

Paired bootstrap differences (95% CI): versus the base model the adapter lowers MAE by 0.36 (0.29–0.43) and raises QWK by 0.37 (0.32–0.41); versus always answering 6.0 it lowers MAE by 0.16 (0.09–0.23). Expected-value scoring lowers MAE by a further 0.07 (0.03–0.10) but does not improve QWK (−0.02; −0.05 to +0.01).

Error by true band (MAE, with the mean predicted band in parentheses):

True band n Base, greedy essay-model, greedy essay-model, expected value
≤ 5.0 287 2.51 (6.92) 1.05 (5.33) 1.18 (5.56)
5.5–6.0 218 1.42 (7.17) 1.12 (6.20) 0.64 (6.25)
6.5–7.0 252 0.65 (7.18) 0.66 (6.46) 0.47 (6.37)
≥ 7.5 243 0.69 (7.23) 1.20 (6.68) 1.39 (6.48)
  • Few distinct scores. With greedy decoding the adapter only answered 7.0 (62% of essays), 5.0 (25%), 4.0 (7%), 3.5 (4%), 6.0 (1%) or 4.5 (<1%); it never produced 5.5, 6.5, 7.5 or 8+. The band is decoded digit by digit, so the most likely first digit wins even when the probability is spread over neighbouring bands. Expected-value scoring does use the in-between bands (mostly 6.5 and 6.0) but still never goes above 7.0.
  • Compressed toward the middle. Essays at 5.0 or below (true mean 4.4) get 5.3 on average; essays at 7.5 or above (true mean 7.9) get 6.7. The model is most reliable for 6.5–7.0 essays and should not be trusted to recognise very weak or very strong writing.
  • The base model is not really scoring. It answers 6.5 or 7.5 for 93% of essays, so its small error on strong essays is not skill.
  • Unseen questions. On the 170 essays whose question never appears in the training data the adapter gets MAE 0.89 / QWK 0.58 (expected value: 0.83 / 0.56), versus 1.47 / 0.09 for the base model and MAE 1.12 for always answering 6.0, so it is not relying on memorised questions.

How this was measured

  • Why not the dataset's test split: all 491 essays in the dataset's test split also appear verbatim in its train split, and 377 of them were among this adapter's 7,000 training examples. Instead, the exact training selection was reproduced (train split, shuffle(seed=42), same filters, first 7,000 kept; it ends at shuffled row 7,001). Evaluation essays come only from rows after that point, with a 50-row safety margin: 2,782 rows, minus 1 invalid row and 515 rows whose essay was an exact or near duplicate (same first 300 alphanumeric characters) of an essay in the training region or of an earlier candidate. That leaves 2,266 unseen essays; a random 1,000 (seed 0) were scored. 170 of them answer a question that never appears in the training region.
  • Prompt: identical for all models: the training system prompt, a Question: … Essay: … user turn, and the LFM3 chat template with enable_thinking=False. The base model is the same weights with the LoRA disabled.
  • Greedy scoring: the assistant turn is prefilled with Overall band:, up to 8 tokens are decoded greedily (repetition penalty 1.0), and the first number is the prediction (all outputs parsed). Without the prefill the adapter starts its answer with Overall band: by itself and gave the same score in 9 of 10 spot checks (the tenth differed by one band), so the prefilled score is a close proxy for normal generation.
  • Expected-value scoring: one batched forward pass over Overall band: d. for d = 3…9 gives P(first digit) (and P(<4)) and, for each digit, P(.5 | d); the score is Σ P(band) × band, rounded to the nearest 0.5. This single variant was fixed before looking at its results.
  • Labels: the dataset's band column; <4 is scored as 3.5. QWK is computed on the half-band scale (0–9 in steps of 0.5). Bootstrap: 2,000 resamples.
  • Run: float16 on a Tesla T4, November 2026; 0.63 s per essay for greedy scoring with the adapter, 0.41 s for the base model, 1.15 s for expected-value scoring.
  • For reference, the official test split (491 essays, 377 seen in training) gives MAE 0.97 / QWK 0.53 with greedy scoring; on its 377 seen essays MAE 0.99 / QWK 0.51, on the other 114 MAE 0.90 / QWK 0.58. The adapter does not score seen essays better, so the overlap does not inflate these numbers, but they should not be read as a held-out result.
  • Per-essay predictions and all metrics: benchmark/metrics.json, benchmark/predictions_heldout.csv, benchmark/predictions_official_test.csv.

Usage

Full evaluation (band + feedback). Use torch.float16 instead of bfloat16 on GPUs without bf16 support (e.g. T4).

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

tok   = AutoTokenizer.from_pretrained("D0zy/essay-model", trust_remote_code=True)
base  = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM3-1.7B", trust_remote_code=True, device_map="auto", dtype=torch.bfloat16)
model = PeftModel.from_pretrained(base, "D0zy/essay-model").eval()

SYSTEM = ("You are a certified IELTS examiner. Evaluate the IELTS Writing Task 2 essay. "
          "First give the overall band score, then detailed feedback on Task Response, "
          "Coherence and Cohesion, Lexical Resource and Grammatical Range and Accuracy.")

def prompt_ids(question, essay):
    msgs = [{"role": "system", "content": SYSTEM},
            {"role": "user", "content": f"Question:\n{question.strip()}\n\nEssay:\n{essay.strip()}"}]
    text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
    return tok(text, add_special_tokens=False)["input_ids"]   # same formatting as in training

ids = torch.tensor([prompt_ids(question, essay)], device=model.device)
out = model.generate(input_ids=ids, attention_mask=torch.ones_like(ids), max_new_tokens=700,
                     do_sample=False, repetition_penalty=1.05)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))

Score only, read from the model's probabilities instead of the greedy digits. On the held-out set this gives a lower average error (MAE 0.94 vs 1.00, within ±1 band 71% vs 65%) but fewer exact hits and an even stronger pull toward 6.0–6.5 (see Evaluation). Reuses tok, model and prompt_ids from above.

t = lambda s: tok(s, add_special_tokens=False)["input_ids"]
PFX = t("Overall band:"); n = len(PFX)
SP, DOT, FIVE = t("Overall band: 6.5")[n], t("Overall band: 6.5")[n + 2], t("Overall band: 6.5")[n + 3]
ZERO = t("Overall band: 6.0")[n + 3]
LT = t("Overall band: <4")[n]                    # " <" token: band "<4", counted as 3.5
DIG = {d: t(f"Overall band: {d}.5")[n + 1] for d in range(3, 10)}

@torch.no_grad()
def band_score(question, essay):
    p = prompt_ids(question, essay) + PFX
    x = torch.tensor([p + [SP, DIG[d], DOT] for d in DIG], device=model.device)
    pr = model(input_ids=x, attention_mask=torch.ones_like(x), logits_to_keep=4).logits.float().softmax(-1)
    p_lt = (pr[0, 0, LT] / (pr[0, 0, LT] + pr[0, 0, SP])).item()       # P("<4")
    p_d = pr[0, 1, list(DIG.values())]; p_d = p_d / p_d.sum()           # P(first digit)
    ev = sum(p_d[i].item() * (d + 0.5 * ((pr[i, 3, FIVE] / (pr[i, 3, ZERO] + pr[i, 3, FIVE])).item() if d < 9 else 0.0))
             for i, d in enumerate(DIG))
    ev = (1 - p_lt) * ev + p_lt * 3.5
    return round(ev * 2) / 2                     # ev itself is a finer-grained score if you need one

print(band_score(question, essay))

License

This model is a Derivative Work of LiquidAI/LFM3-1.7B and is distributed under the LFM Open License v1.0 (see the LICENSE file in this repository; original: https://huggingface.co/LiquidAI/LFM3-1.7B)

  • Modifications: LoRA fine-tuning on IELTS essay evaluation data (by D0zy). The original model weights were not otherwise changed.
  • All copyright and attribution notices of the original work are retained.
  • Commercial use is only permitted for entities below the revenue threshold defined in the license (USD 10M annual revenue); see the license for details.
  • This project is not affiliated with or endorsed by Liquid AI. "LFM" and "Liquid AI" are trademarks of Liquid AI.

Limitations

  • Scores are model estimates learned from a community dataset, not official IELTS results. Use for practice and feedback only.
  • On unseen essays the typical error is about one band (MAE 0.94–1.00 depending on scoring), roughly 30–35% of scores are more than one band off, and scores are pulled toward the middle of the scale: weak essays are over-scored and essays at 7.5 or above are under-scored (it never predicted above 7.0 on the held-out set). Do not use it for decisions about real candidates.
  • The written feedback was not evaluated quantitatively; only the overall band was benchmarked.
  • English, IELTS Writing Task 2 only. Training examples were at most 2,048 tokens long.
  • The dataset does not document how its band scores and feedback were produced, has no stated license, contains many duplicate essays, and its test split is contained in its train split.
  • License terms of the base model apply.