Downloads · 30 days
12
10% of all-time downloads
vltruong01/amazon-all-beauty-led-large-summarization
amazon-all-beauty-led-large-summarization is a summarization model from vltruong01. Use it when you need a shorter version of a longer text. It is set up for transformers. The card lists the license as apache-2.0.
A fine-tuned allenai/led-large-16384 model for product-level multi-review summarization in the Amazon Reviews 2023 AllBeauty category.
Downloads · 30 days
12
10% of all-time downloads
All-time downloads
122
Public
Parameters
460M
1.8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.8 GB · 100%
From the Hugging Face model README
A fine-tuned allenai/led-large-16384 model for product-level multi-review summarization in the Amazon Reviews 2023 All_Beauty category.
The model takes multiple customer reviews for one product and generates a single abstractive summary that captures the main review consensus, recurring strengths, and meaningful complaints.
Input: product title + multiple review blocks
Output: one product-level summary
The product's numeric rating is not generated by the model. It is computed separately from the original review ratings.
Fastest option: open
AllBeauty_LED_Large_Inference.ipynbif you want a ready-to-run example without reading the full training notebook.
pip install -U transformers torch sentencepiece
import torch
from transformers import AutoTokenizer, LEDForConditionalGeneration
MODEL_ID = "vltruong01/amazon-all-beauty-led-large-summarization"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = LEDForConditionalGeneration.from_pretrained(
MODEL_ID,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
model.eval()
The model was trained on inputs with this structure:
Product: Example Beauty Product
[Review 1]
Rating: 5/5
Title: Works very well
Text: I have used this product for several weeks and it works well...
[Review 2]
Rating: 4/5
Title: Good but expensive
Text: The quality is good, although the price is higher than expected...
[Review 3]
Rating: 2/5
Title: Not for me
Text: I experienced irritation and stopped using it...
Keep each review as a complete block whenever possible.
LED uses sparse attention. The inference code below reproduces the global-attention pattern used in training: the first token, the product-title line, each review header, and each rating line receive global attention.
import re
import torch
MAX_SOURCE_LENGTH = 4096
def build_global_attention_mask(source, input_ids, attention_mask, tokenizer):
global_attention = torch.zeros_like(input_ids)
# Always give global attention to the first non-padding token.
global_attention[:, 0] = 1
lines = source.splitlines()
important_prefixes = ("Product:", "[Review ", "Rating:")
important_texts = [
line.strip()
for line in lines
if line.strip().startswith(important_prefixes)
]
for text in important_texts:
token_ids = tokenizer(
text,
add_special_tokens=False,
)["input_ids"]
if not token_ids:
continue
first_token = token_ids[0]
matches = (
(input_ids[0] == first_token)
& (attention_mask[0] == 1)
).nonzero(as_tuple=False)
for match in matches:
global_attention[0, match.item()] = 1
return global_attention
source = '''Product: Example Beauty Product
[Review 1]
Rating: 5/5
Title: Works very well
Text: I have used this product for several weeks and it works well.
[Review 2]
Rating: 4/5
Title: Good but expensive
Text: The quality is good, although the price is higher than expected.
[Review 3]
Rating: 2/5
Title: Not for me
Text: I experienced irritation and stopped using it.
'''
inputs = tokenizer(
source,
return_tensors="pt",
max_length=MAX_SOURCE_LENGTH,
truncation=True,
padding=False,
)
input_ids = inputs["input_ids"].to(device)
attention_mask = inputs["attention_mask"].to(device)
global_attention_mask = build_global_attention_mask(
source,
input_ids,
attention_mask,
tokenizer,
).to(device)
with torch.inference_mode():
generated = model.generate(
input_ids=input_ids,
attention_mask=attention_mask,
global_attention_mask=global_attention_mask,
num_beams=6,
max_new_tokens=192,
no_repeat_ngram_size=3,
repetition_penalty=1.05,
early_stopping=True,
)
summary = tokenizer.decode(
generated[0],
skip_special_tokens=True,
)
print(summary)
If you only want to use the trained model, open:
AllBeauty_LED_Large_Inference.ipynb
The notebook is intentionally much shorter than the training notebook and contains only the steps required for inference:
install dependencies
↓
load tokenizer + fine-tuned LED-Large
↓
paste one product's review collection
↓
build structured global attention
↓
generate one product-level summary
↓
optionally compute the numeric rating separately
The inference notebook reproduces the same structural global-attention pattern used during training.
Global attention is assigned to:
Product: line,[Review N] header,Rating: line.This matters because LED uses sparse attention for long inputs. These structural anchors help the model connect product identity, review boundaries, and ratings across a long multi-review document.
The notebook also keeps the numeric product rating outside the model. LED generates only the summary.
The model performs multi-review aggregation, not single-review summarization.
It is intended to learn patterns such as:
The model should not simply concatenate or extract individual review sentences.
Training data comes from:
vltruong01/amazon-all-beauty-led-summarization
The dataset was derived from Amazon Reviews 2023 All_Beauty product reviews.
Each example contains fields such as:
parent_asin
product_title
rating
num_reviews
source
target_summary
target_word_count
target_qc_ok
source_title_mismatch
mismatch
Before training, rows failing quality control or marked as source/title mismatches were excluded.
The final training experiment used:
| Split | Examples |
|---|---|
| Train | 1,567 |
| Validation | 196 |
| Held-out test | 196 |
| Total clean examples | 1,959 |
The split was deterministic with seed 42.
The target summaries used for training are synthetic reference summaries generated by a teacher model, not human-written gold summaries.
They were produced under constraints intended to:
This distinction is important when interpreting the evaluation results below: automatic metrics compare LED outputs against these synthetic teacher-generated references.
| Setting | Value |
|---|---|
| Base model | allenai/led-large-16384 |
| Maximum source length | 4096 tokens |
| Maximum target length | 192 tokens |
| Epochs | 3 |
| Train batch size / device | 1 |
| Eval batch size / device | 1 |
| Gradient accumulation | 8 |
| Effective batch size | 8 |
| Learning rate | 1e-5 |
| Weight decay | 0.01 |
| Warmup ratio | 0.05 |
| Label smoothing | 0.05 |
| Precision | FP16 |
| Optimizer | AdamW |
| Gradient checkpointing | Enabled |
| Beam size | 6 |
| No-repeat n-gram size | 3 |
| Repetition penalty | 1.05 |
| Seed | 42 |
This was a full fine-tuning of LED-Large, not LoRA.
Sparse global attention was assigned to:
[Review N] block,Rating: line.This gives LED explicit anchors for the product identity and review boundaries across long inputs.
Evaluation was performed on the 196-example held-out test split.
| Metric | Score |
|---|---|
| ROUGE-1 | 0.4806 |
| ROUGE-2 | 0.1607 |
| ROUGE-L | 0.3264 |
| ROUGE-Lsum | 0.3263 |
| BERTScore Precision | 0.9074 |
| BERTScore Recall | 0.9052 |
| BERTScore F1 | 0.9062 |
| Test loss | 2.6579 |
Validation loss for the final run:
2.6452
Automatic metrics are useful for reproducibility, but they do not fully measure factual consistency, consensus weighting, or product-identity preservation.
A manual audit of the 196 held-out generations found several strengths:
Observed limitations include:
These limitations are important for downstream use.
A simple application can combine the deterministic product rating with the generated review summary:
Rating: 4.3/5
Summary: Customers generally appreciate ...
The rating should be computed from the original review ratings in application code.
Do not ask LED to generate the numeric rating.
The full experiment notebook is included in this repository:
AllBeauty_LED_Large_Training.ipynb
The training workflow is:
prepared product-level review dataset
↓
quality filtering
↓
deterministic train / validation / test split
↓
LED-Large tokenization
↓
structured global attention
↓
full fine-tuning
↓
best-model selection
↓
held-out generation
↓
ROUGE + BERTScore + qualitative diagnostics
Experiment artifacts are stored under:
artifacts/
Typical files include:
experiment_config.json
final_metrics.json
split_manifest.json
test_predictions.csv
amazon-all-beauty-led-large-summarization/
├── README.md
├── AllBeauty_LED_Large_Training.ipynb
├── AllBeauty_LED_Large_Inference.ipynb
├── config.json
├── generation_config.json
├── model.safetensors
├── tokenizer.json
├── tokenizer_config.json
├── special_tokens_map.json
├── merges.txt
├── vocab.json
└── artifacts/
├── experiment_config.json
├── final_metrics.json
├── split_manifest.json
└── test_predictions.csv
The model files are stored at the repository root so the model can be loaded directly with:
LEDForConditionalGeneration.from_pretrained(
"vltruong01/amazon-all-beauty-led-large-summarization"
)
| Goal | File |
|---|---|
| Run the model on your own review collection | AllBeauty_LED_Large_Inference.ipynb |
| Load the trained model programmatically | repository root |
| Reproduce training and evaluation | AllBeauty_LED_Large_Training.ipynb |
| Inspect the experiment configuration | artifacts/experiment_config.json |
| Inspect final metrics | artifacts/final_metrics.json |
| Inspect exact split membership | artifacts/split_manifest.json |
| Inspect held-out model generations | artifacts/test_predictions.csv |
Use the same structured format as training:
Product: <product title>
[Review 1]
Rating: <rating>/5
Title: <review title>
Text: <review text>
[Review 2]
Rating: <rating>/5
Title: <review title>
Text: <review text>
For best results:
The intended output is:
Suitable uses include:
This model has several important limitations:
For high-stakes or user-facing deployment, summaries should be treated as generated text and checked against the source reviews.
Training dataset:
vltruong01/amazon-all-beauty-led-summarization
Source-only review dataset:
vltruong01/amazon-all-beauty-led-reviews
Base model:
allenai/led-large-16384Dataset source:
This repository is provided for research and educational use.