Instructions to use Kamyar-zeinalipour/Llama2-13B-Syntax-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Kamyar-zeinalipour/Llama2-13B-Syntax-Instruct with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-chat-hf") model = PeftModel.from_pretrained(base_model, "Kamyar-zeinalipour/Llama2-13B-Syntax-Instruct") - Notebooks
- Google Colab
- Kaggle
Update card
Browse files
README.md
CHANGED
|
@@ -1,67 +1,89 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
- name: llama13B_LORA_AFG_32_64_v4
|
| 10 |
-
results: []
|
| 11 |
---
|
| 12 |
|
| 13 |
-
<
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
It achieves the following results on the evaluation set:
|
| 20 |
-
- Loss: 0.8997
|
| 21 |
|
| 22 |
-
##
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
## Training
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
- learning_rate: 0.0001
|
| 40 |
-
- train_batch_size: 8
|
| 41 |
-
- eval_batch_size: 8
|
| 42 |
-
- seed: 100
|
| 43 |
-
- distributed_type: multi-GPU
|
| 44 |
-
- num_devices: 2
|
| 45 |
-
- gradient_accumulation_steps: 4
|
| 46 |
-
- total_train_batch_size: 64
|
| 47 |
-
- total_eval_batch_size: 16
|
| 48 |
-
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
| 49 |
-
- lr_scheduler_type: cosine
|
| 50 |
-
- num_epochs: 3.0
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|:-------------:|:-----:|:----:|:---------------:|
|
| 56 |
-
| 0.9094 | 1.0 | 125 | 0.9227 |
|
| 57 |
-
| 0.8714 | 2.0 | 251 | 0.9003 |
|
| 58 |
-
| 0.8745 | 2.99 | 375 | 0.8997 |
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
##
|
| 62 |
|
| 63 |
-
|
| 64 |
-
- Transformers 4.38.2
|
| 65 |
-
- Pytorch 2.1.2+cu121
|
| 66 |
-
- Datasets 2.16.1
|
| 67 |
-
- Tokenizers 0.15.0
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: meta-llama/Llama-2-13b-chat-hf
|
| 3 |
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
license: llama2
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
datasets:
|
| 9 |
+
- Kamyar-zeinalipour/Essay-Syntax-Instruct
|
| 10 |
tags:
|
| 11 |
+
- education
|
| 12 |
+
- writing-feedback
|
| 13 |
+
- syntax
|
| 14 |
+
- lora
|
| 15 |
+
- peft
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
+
<div align="center">
|
| 19 |
+
|
| 20 |
+
# Llama2-13B-Syntax-Instruct
|
| 21 |
+
|
| 22 |
+
**Llama-2-13b-chat fine-tuned to give students feedback on essay syntax**
|
| 23 |
+
|
| 24 |
+
[](https://arxiv.org/abs/2501.07740) [](https://github.com/KamyarZeinalipour/Essay-Syntax-Feedback) [](https://huggingface.co/collections/Kamyar-zeinalipour/automated-syntax-feedback-aieer-2024-6af487599293af6e63c227f9)
|
| 25 |
+
|
| 26 |
+
</div>
|
| 27 |
|
| 28 |
+
Reads an English student essay and returns structured feedback on its syntax across eight
|
| 29 |
+
categories β spelling, conjunctions and connectives, modifiers, prepositions, modal verbs,
|
| 30 |
+
punctuation, articles and pronouns β with examples from the essay and suggestions for each.
|
| 31 |
+
A LoRA adapter for [Llama-2-13b-chat](https://huggingface.co/meta-llama/Llama-2-13b-chat-hf) trained on
|
| 32 |
+
[Essay-Syntax-Instruct](https://huggingface.co/datasets/Kamyar-zeinalipour/Essay-Syntax-Instruct).
|
| 33 |
|
| 34 |
+
From [*Advancing Student Writing Through Automated Syntax Feedback*](https://arxiv.org/abs/2501.07740) (AIEER 2024). Code: [Essay-Syntax-Feedback](https://github.com/KamyarZeinalipour/Essay-Syntax-Feedback).
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
## Results
|
| 37 |
|
| 38 |
+
ROUGE against the reference feedback, base β fine-tuned:
|
| 39 |
|
| 40 |
+
| Model | ROUGE-1 | ROUGE-2 | ROUGE-L |
|
| 41 |
+
|---|---|---|---|
|
| 42 |
+
| Llama-2-7b-chat | 0.351 β **0.477** | 0.146 β **0.337** | 0.185 β **0.343** |
|
| 43 |
+
| Llama-2-13b-chat | 0.328 β **0.476** | 0.148 β **0.340** | 0.214 β **0.347** |
|
| 44 |
+
| Mistral-7B-Instruct-v0.2 | 0.366 β **0.514** | 0.144 β **0.375** | 0.205 β **0.369** |
|
| 45 |
|
| 46 |
+
## Usage
|
| 47 |
|
| 48 |
+
```python
|
| 49 |
+
import torch
|
| 50 |
+
from peft import PeftModel
|
| 51 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 52 |
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-13b-chat-hf")
|
| 54 |
+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-chat-hf", torch_dtype=torch.bfloat16, device_map="auto")
|
| 55 |
+
model = PeftModel.from_pretrained(model, "Kamyar-zeinalipour/Llama2-13B-Syntax-Instruct").merge_and_unload()
|
| 56 |
+
```
|
| 57 |
|
| 58 |
+
## Training
|
| 59 |
|
| 60 |
+
LoRA r = 32, Ξ± = 64, dropout 0.1; 3 epochs; AdamW, learning rate 1e-4 with cosine decay;
|
| 61 |
+
8 sequences per GPU Γ 4 accumulation steps; up to 2,048 tokens; bf16, DeepSpeed.
|
| 62 |
+
Script: [`scripts/`](https://github.com/KamyarZeinalipour/Essay-Syntax-Feedback/tree/main/scripts).
|
| 63 |
|
| 64 |
+
## Models from this paper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
| Base model | Adapter | ROUGE-L (base β fine-tuned) |
|
| 67 |
+
|---|---|---|
|
| 68 |
+
| [Llama-2-7b-chat](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf) | [Llama2-7B-Syntax-Instruct](https://huggingface.co/Kamyar-zeinalipour/Llama2-7B-Syntax-Instruct) | 0.185 β **0.343** |
|
| 69 |
+
| [Llama-2-13b-chat](https://huggingface.co/meta-llama/Llama-2-13b-chat-hf) | **Llama2-13B-Syntax-Instruct** (this model) | 0.214 β **0.347** |
|
| 70 |
+
| [Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) | [Mistral7B-Syntax-Instruct](https://huggingface.co/Kamyar-zeinalipour/Mistral7B-Syntax-Instruct) | 0.205 β **0.369** |
|
| 71 |
|
| 72 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
```bibtex
|
| 75 |
+
@inproceedings{zeinalipour2024advancing,
|
| 76 |
+
title = {Advancing Student Writing Through Automated Syntax Feedback},
|
| 77 |
+
author = {Kamyar Zeinalipour and Mehak Mehak and Fatemeh Parsamotamed and Marco Maggini and Marco Gori},
|
| 78 |
+
booktitle = {AI in Education and Educational Research (AIEER 2024)},
|
| 79 |
+
pages = {52--66},
|
| 80 |
+
year = {2024},
|
| 81 |
+
publisher = {Springer},
|
| 82 |
+
doi = {10.1007/978-3-031-93409-4_5},
|
| 83 |
+
url = {https://arxiv.org/abs/2501.07740}
|
| 84 |
+
}
|
| 85 |
+
```
|
| 86 |
|
| 87 |
+
## License
|
| 88 |
|
| 89 |
+
Released under the base model's license (`llama2`).
|
|
|
|
|
|
|
|
|
|
|
|