Downloads · 30 days
46
21% of all-time downloads
vltruong01/IELTSWritingTask2-Qwen2.5-7B-QLoRA
IELTSWritingTask2-Qwen2.5-7B-QLoRA is a text generation model from vltruong01. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A QLoRA adapter for Qwen/Qwen2.5-7B-Instruct, fine-tuned to generate complete IELTS Writing Task 2 essays from essay prompts.
Downloads · 30 days
46
21% of all-time downloads
All-time downloads
221
Public
Repo size
980 MB
Likes
0
Public
Click a slice to open those files.
.safetensors323 MB · 95%
From the Hugging Face model README
A QLoRA adapter for Qwen/Qwen2.5-7B-Instruct, fine-tuned to generate complete IELTS Writing Task 2 essays from essay prompts.
The model is designed for essay generation, not IELTS scoring.
Input: an IELTS Writing Task 2 question
Output: one complete academic essay, typically around 280–330 words
This repository contains the LoRA adapter, not a fully merged 7B model. The Qwen2.5-7B-Instruct base model is loaded separately and the adapter is attached with PEFT.
pip install -U transformers peft accelerate bitsandbytes sentencepiece
import torch
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
)
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-7B-Instruct"
ADAPTER_REPO = "vltruong01/IELTSWritingTask2-Qwen2.5-7B-QLoRA"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(
ADAPTER_REPO,
trust_remote_code=True,
)
if tokenizer.pad_token_id is None:
tokenizer.pad_token = tokenizer.eos_token
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True,
)
model = PeftModel.from_pretrained(
base_model,
ADAPTER_REPO,
)
model.eval()
SYSTEM_PROMPT = (
"You are an expert IELTS Writing Task 2 writer aiming for Band 8 or higher. "
"Write a complete academic essay that answers every part of the task and maintains a clear position. "
"Develop each main idea with specific explanation and a relevant example where appropriate. "
"Prioritize grammatical accuracy, logical cohesion, and precise natural vocabulary over rare or forced words. "
"Avoid headings, bullet points, repetition, and memorized templates."
)
question = '''
Some people believe that artificial intelligence will improve people's lives,
while others think it will create serious problems for society.
Discuss both views and give your own opinion.
'''
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{
"role": "user",
"content": (
"IELTS Writing Task 2\n\n"
f"{question.strip()}\n\n"
"Write only the final essay, approximately 280–330 words."
),
},
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(
prompt,
return_tensors="pt",
add_special_tokens=False,
).to(model.device)
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=520,
do_sample=False,
repetition_penalty=1.03,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
new_tokens = outputs[0, inputs["input_ids"].shape[1]:]
essay = tokenizer.decode(
new_tokens,
skip_special_tokens=True,
).strip()
print(essay)
print("\nWord count:", len(essay.split()))
For a ready-to-run notebook, see:
IELTS_Qwen25_7B_Inference.ipynb
| Item | Value |
|---|---|
| Base model | Qwen/Qwen2.5-7B-Instruct |
| Task | IELTS Writing Task 2 essay generation |
| Language | English |
| Fine-tuning | QLoRA |
| Adapter type | PEFT LoRA |
| Quantization during training | 4-bit NF4 |
| Compute precision | FP16 |
| LoRA rank | 32 |
| LoRA alpha | 64 |
| LoRA dropout | 0.05 |
| Maximum sequence length | 768 |
| License | Apache-2.0 |
The LoRA adapter targets:
q_proj
k_proj
v_proj
o_proj
gate_proj
up_proj
down_proj
The training notebook downloads the source dataset directly from Hugging Face:
chillies/ielts-writing-task2-essays
No pre-generated train, validation, or test dataset files are required.
The preprocessing pipeline runs in memory:
Overall band >= 8.0
Task Achievement >= 7.0
Coherence & Cohesion >= 7.0
Lexical Resource >= 7.0
Grammatical Range & Accuracy >= 7.0
Essay length: 250–420 words
After filtering and exact essay de-duplication:
| Statistic | Value |
|---|---|
| Essays | 713 |
| Literal unique questions | 383 |
| Topics | 25 |
| Mean overall band | 8.302 |
Average component scores:
| Criterion | Mean |
|---|---|
| Task Achievement | 8.123 |
| Coherence & Cohesion | 7.805 |
| Lexical Resource | 8.066 |
| Grammatical Range & Accuracy | 8.756 |
A simple random row split would be inappropriate because several essays can correspond to the same or nearly identical IELTS question.
To reduce question leakage, near-duplicate prompts are grouped before splitting.
The split is performed by question_group, not by individual essay row.
| Split | Essays | Question Groups | Topics | Mean Band |
|---|---|---|---|---|
| Train | 626 | 114 | 25 | 8.299 |
| Validation | 51 | 14 | 9 | 8.324 |
| Test | 36 | 14 | 11 | 8.319 |
Because entire question groups stay together, the final essay-row proportions are not exactly 80/10/10.
The split is deterministic with a fixed random seed. The split files themselves are not stored in this repository.
Base model: Qwen/Qwen2.5-7B-Instruct
QLoRA:
- 4-bit NF4
- double quantization
- FP16 compute
LoRA:
- rank: 32
- alpha: 64
- dropout: 0.05
- target modules: attention + MLP projections
Training:
- epochs: 3
- per-device train batch size: 1
- per-device validation batch size: 1
- gradient accumulation: 8
- effective batch size: 8
- learning rate: 1e-4
- scheduler: cosine
- warmup ratio: 0.08
- optimizer: paged_adamw_8bit
- gradient checkpointing: enabled
- maximum sequence length: 768
Only assistant-response tokens contribute to the language-model loss. System and user prompt tokens are masked.
The best checkpoint is selected using validation loss:
load_best_model_at_end=True
metric_for_best_model="eval_loss"
greater_is_better=False
The best observed validation loss was reached around step 80.
| Step | Training Loss | Validation Loss |
|---|---|---|
| 20 | 2.6705 | 2.6105 |
| 40 | 2.5850 | 2.5829 |
| 60 | 2.4710 | 2.5726 |
| 80 | 2.6456 | 2.5646 |
| 100 | 2.4191 | 2.5794 |
| 120 | 2.3801 | 2.5853 |
| 180 | 2.1274 | 2.6384 |
| 220 | 2.2319 | 2.6405 |
The best validation checkpoint is restored before the final LoRA adapter is saved.
Validation loss is a language-model objective and should not be interpreted as an IELTS band score.
The held-out test split contains:
36 essays
14 unseen question groups
11 topics
For qualitative generation analysis, representative unseen prompts are selected from the held-out question groups rather than generating once for every reference essay row.
Existing generated examples are available under:
artifacts/test_results/
Recommended human evaluation dimensions:
Generated essays should not be assumed to have a specific IELTS band score solely because the training examples were high-scoring essays.
The full workflow is provided in:
IELTSWritingtask2_Qwen25_7B.ipynb
Pipeline:
Hugging Face source dataset
↓
quality filtering
↓
exact essay de-duplication
↓
near-duplicate question grouping
↓
deterministic group-aware split
↓
QLoRA fine-tuning
↓
best-checkpoint selection
↓
final LoRA adapter
The dataset is loaded directly from Hugging Face during the run. Train / validation / test JSONL files are not required or stored in this repository.
Experiment settings are recorded in:
artifacts/experiment_config.json
IELTSWritingTask2-Qwen2.5-7B-QLoRA/
├── README.md
├── IELTSWritingtask2_Qwen25_7B.ipynb
├── IELTS_Qwen25_7B_Inference.ipynb
├── adapter_config.json
├── adapter_model.safetensors
├── added_tokens.json
├── chat_template.jinja
├── merges.txt
├── special_tokens_map.json
├── tokenizer.json
├── tokenizer_config.json
├── vocab.json
└── artifacts/
├── experiment_config.json
└── test_results/
├── qwen25_ielts_quality_v2_test_outputs.csv
└── qwen25_ielts_quality_v2_test_outputs.jsonl
| Goal | File |
|---|---|
| Generate an essay with the trained model | IELTS_Qwen25_7B_Inference.ipynb |
| Reproduce preprocessing and training | IELTSWritingtask2_Qwen25_7B.ipynb |
| Inspect exact experiment settings | artifacts/experiment_config.json |
| Inspect generated held-out examples | artifacts/test_results/ |
Use a normal IELTS Writing Task 2 question, for example:
Some people think that governments should invest more money in public transport,
while others believe that building more roads is more important.
Discuss both views and give your own opinion.
You do not need to manually add Qwen special tokens. Use tokenizer.apply_chat_template() as shown above.
The intended output is:
Suitable uses include:
For serious IELTS assessment, human evaluation using the official Writing Task 2 criteria is recommended.
This is an experimental educational and research model.
It is not affiliated with IELTS, Cambridge University Press & Assessment, the British Council, or IDP Education.
Generated outputs should not be interpreted as official IELTS assessment or guaranteed band-score performance.