Downloads · 30 days
0
MohammadKhosravi/llama3.1-8b-prefixmemory-cefr-balanced-topic-aligned
llama3.1-8b-prefixmemory-cefr-balanced-topic-aligned is a text generation model from MohammadKhosravi. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
This repository contains the PrefixMemory-Tuning (PMT) baseline developed for controllable CEFR-level text generation.
Downloads · 30 days
0
Access
Public
Updated Aug 4, 2026
Repo size
39.8 MB
Likes
1
Public
Click a slice to open those files.
.pt34.7 MB · 87%
From the Hugging Face model README
This repository contains the PrefixMemory-Tuning (PMT) baseline developed for controllable CEFR-level text generation.
The model extends Meta Llama-3.1-8B-Instruct with a lightweight external PrefixMemory controller while keeping all base LLM parameters frozen. Only the PrefixMemory controller is optimized during training.
This model serves as the baseline architecture against which all subsequent hierarchical and dual-stream ablation models are compared.
Foundation Model
Only the PrefixMemory controller is trainable.
The architecture follows the PrefixMemory-Tuning paradigm by attaching a lightweight external memory controller to every transformer attention block.
<p align="center"> <img src="images/PMT_Arc.png" width="800"> </p> <p align="center"> <b>Figure 1.</b> Overall architecture of the CEFR controller integrated with PrefixMemory.. </p>For a target CEFR level
$$ c \in {A1, A2, B1, B2, C1, C2} $$
the controller first retrieves an embedding
$$ e_c = \mathrm{Embedding}(c) $$
which is transformed by a two-layer MLP
$$ m = \mathrm{MLP}(e_c) $$
The modulation vector is reshaped into
$$ m \in \mathbb{R}^{32 \times r} $$
where
For transformer layer $l$, query states are projected into the low-rank PrefixMemory space
$$ Q_l = XW^{\mathrm{down}}_l $$
where
The controller applies element-wise modulation
$$ \phi(Q_l) = \mathrm{ELU}!\left(Q_l \odot m_l\right) $$
The external PrefixMemory bias becomes
$$ B_l = \phi(Q_l)W^{\mathrm{up}}_l $$
where
$$ W^{\mathrm{up}} \in \mathbb{R}^{64 \times 4096} $$
Finally,
H_l^{\mathrm{attn}} + \alpha B_l $$
where
Only the PrefixMemory controller parameters are optimized.
The frozen Llama backbone receives the modified hidden representations.
Training minimizes the standard causal language modeling objective
\sum_t \log P(x_t \mid x_{<t}, c) $$
using masked prompt tokens.
Training uses a balanced subset derived from the EFCAMDAT learner corpus.
Original dataset:
https://ef-lab.mmll.cam.ac.uk/EFCAMDAT.html
Due to the EFCAMDAT data usage policy, the processed training subset cannot be redistributed.
| Column | Description |
|---|---|
| topic_title | Writing prompt |
| clean_text | Human learner response |
| cefr | Target CEFR level |
Balanced across all CEFR levels.
| CEFR | Samples |
|---|---|
| A1 | 1,000 |
| A2 | 1,000 |
| B1 | 1,000 |
| B2 | 1,000 |
| C1 | 1,000 |
| C2 | 1,000 |
Total:
6,000 samples
Best checkpoint:
Epoch 2
Validation Perplexity:
7.08
[
{
"epoch": 1,
"train_loss": 2.1147,
"val_loss": 2.0288,
"val_ppl": 7.61
},
{
"epoch": 2,
"train_loss": 1.8625,
"val_loss": 1.9573,
"val_ppl": 7.08
},
{
"epoch": 3,
"train_loss": 1.5514,
"val_loss": 2.0191,
"val_ppl": 7.53
},
{
"epoch": 4,
"train_loss": 1.1617,
"val_loss": 2.2208,
"val_ppl": 9.21
},
{
"epoch": 5,
"train_loss": 0.7790,
"val_loss": 2.5407,
"val_ppl": 12.69
}
]
Balanced benchmark constructed from held-out EFCAMDAT prompts.
Dataset columns
| Column |
|---|
| topic_id |
| topic_title |
| cefr |
Distribution
| CEFR | Samples |
|---|---|
| A1 | 117 |
| A2 | 117 |
| B1 | 117 |
| B2 | 117 |
| C1 | 117 |
| C2 | 117 |
============================================================
📊 FINAL COMPILED MACRO-STATISTICS (PREFIXMEMORY-TUNING BASELINE)
============================================================
Total Processed : 702
Strict Accuracy : 56.27%
Adjacent Accuracy : 73.36%
Mean Abs Error (MAE) : 0.9103
Avg MDD Score : 1.77
Avg Reading Ease : 83.51
Avg Sentence Drift : 2.30 levels
Avg Perplexity : (Computed externally)
============================================================
📈 PERFORMANCE BREAKDOWN BY CEFR TARGET LEVEL
============================================================
strict_accuracy avg_mdd avg_flesch avg_drift
target_cefr
-------------------------------------------------------------
A1 74.36 1.35 89.07 1.01
A2 69.23 1.67 87.02 1.73
B1 60.68 1.85 83.37 2.07
B2 50.43 1.87 82.56 2.94
C1 45.30 1.93 78.48 2.86
C2 37.61 1.95 80.55 3.20
============================================================
📝 DETAILED CLASSIFICATION REPORT
============================================================
precision recall f1-score support
A1 0.56 0.74 0.64 117
A2 0.57 0.69 0.62 117
B1 0.46 0.61 0.53 117
B2 0.48 0.50 0.49 117
C1 0.73 0.45 0.56 117
C2 0.77 0.38 0.51 117
-------------------------------------------------------------
Accuracy 0.56 702
Macro Avg 0.60 0.56 0.56 702
Weighted Avg 0.60 0.56 0.56 702
============================================================
📊 FINAL COMPILED MACRO-STATISTICS (BASE LLM)
============================================================
Total Processed : 690
Strict Accuracy : 24.64%
Adjacent Accuracy : 63.19%
Mean Abs Error (MAE) : 1.3275
Avg MDD Score : 2.00
Avg Reading Ease : 49.47
Avg Sentence Drift : 3.04 levels
Avg Perplexity : 4.14
============================================================
📈 PERFORMANCE BREAKDOWN BY CEFR TARGET LEVEL
============================================================
strict_accuracy avg_mdd avg_flesch avg_drift avg_perplexity
target_cefr
-------------------------------------------------------------------------
A1 16.24 1.73 82.56 3.25 5.16
A2 23.08 1.64 85.44 3.27 5.12
B1 17.39 2.03 57.80 3.11 3.86
B2 41.74 2.15 34.18 2.97 3.32
C1 33.63 2.24 18.95 2.94 3.59
C2 15.93 2.25 15.54 2.69 3.74
============================================================
📝 DETAILED CLASSIFICATION REPORT
============================================================
precision recall f1-score support
A1 0.28 0.16 0.20 117
A2 0.38 0.23 0.29 117
B1 0.21 0.17 0.19 115
B2 0.22 0.42 0.29 115
C1 0.24 0.34 0.28 113
C2 0.23 0.16 0.19 113
-------------------------------------------------------------
Accuracy 0.25 690
Macro Avg 0.26 0.25 0.24 690
Weighted Avg 0.26 0.25 0.24 690
MohammadKhosravi/ielts-cefr-benchmark-prompts
A manually curated benchmark containing IELTS-style prompts designed to evaluate prompt generalization.
Dataset:
https://huggingface.co/datasets/MohammadKhosravi/ielts-cefr-benchmark-prompts
Columns
| Column |
|---|
| prompt |
| cefr |
Distribution
Balanced
| CEFR | Samples |
|---|---|
| A1 | 50 |
| A2 | 50 |
| B1 | 50 |
| B2 | 50 |
| C1 | 50 |
| C2 | 50 |
Total:
300 prompts
| Metric | PrefixMemory | Base Llama |
|---|---|---|
| Strict Accuracy | 44.00% | 18.33% |
| Adjacent Accuracy | 71.67% | 54.33% |
| MAE | 0.9933 | 1.5733 |
| Average MDD | 1.96 | 2.07 |
| Reading Ease | 75.43 | 45.18 |
| Sentence Drift | 2.62 | 2.53 |
This model is intended for research on
If you use this model, please cite: