--- base_model: - google-t5/t5-small language: - en library_name: transformers tags: - Summarization --- ## Model Description t5-small-amazon-reviews-summarization-finetuned-8bit-lora is a fine-tuned version of the T5-small model, adapted for the task of summarizing Amazon product reviews. The model has been fine-tuned using Low-Rank Adaptation (LoRA) techniques and 8-bit quantization, allowing for efficient training and inference while maintaining performance. ### Model Architecture ## Training Data The model was fine-tuned on a dataset of Amazon product reviews on products of the beauty category, with corresponding summaries. ## Training Procedure ### Preprocessing ### Fine-tuning Configuration LoRA Configuration: Rank (r): 8 Alpha: 16 Dropout: 0.5 Task Type: SEQ_2_SEQ_LM (Sequence-to-Sequence Language Modeling) Quantization Configuration: Load in 8-bit: True (using BitsAndBytesConfig) Training Arguments: Output Directory: ./model/t5-small-amazon-review-summarization Evaluation Strategy: Every 1,000 steps Learning Rate: 2e-7 Per Device Training Batch Size: 2 Per Device Evaluation Batch Size: 8 Max Steps: 40,000 Logging Steps: 1,000 Save Steps: 1,000 Load Best Model at End: True Predict with Generate: True Generation Max Length: 512 Generation Num Beams: 5 ### Training Environment Hardware Used: Single NVIDIA RTX 4070 8GB Frameworks and Libraries: Transformers Datasets PEFT BitsAndBytes Evaluate PyTorch ## Metrics The model was tested using BERTScorer to test the accuracy of the generated summaries for the reviews. Test set size of 3.8k pairs of reviews and summary. ## Intended Use The model is designed to generate concise summaries of Amazon product reviews. It can be utilized in applications such as: ## How to Use ```python from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, BitsAndBytesConfig from peft import LoraConfig, PeftModel def generate_summary(text): inputs = tokenizer( text, return_tensors='pt', padding=True, truncation=True, max_length=2048, ).to(device) summary_ids = model.generate( input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'], max_length=512, top_k=5, top_p=0.95, temperature=0.7, num_return_sequences=10, no_repeat_ngram_size=2, do_sample=True, ) summary = [tokenizer.decode( summary_id, skip_special_tokens=True, clean_up_tokenization_spaces=True, ) for summary_id in summary_ids] return summary tokenizer = AutoTokenizer.from_pretrained("Chryslerx10/t5-small-amazon-reviews-summarization-finetuned-8bit-lora") model = AutoModelForSeq2SeqLM.from_pretrained( "t5-small", device_map="auto", ) model = PeftModel.from_pretrained(model, "Chryslerx10/t5-small-amazon-reviews-summarization-finetuned-8bit-lora", device_map='auto') generate_summary("summarize: " + ".... reviews .....") ``` ## Limitations and Biases