Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Model Card: t5-summary-finetuned-kw-fp16
|
2 |
+
# Model Overview
|
3 |
+
- **Model Name:** t5-summary-finetuned-kw-fp16
|
4 |
+
- **Base Model:** T5-base (t5-base from Hugging Face)
|
5 |
+
- **Date:** March 19, 2025
|
6 |
+
- **Version:** 1.0
|
7 |
+
- **Task:** Keyword-Based Text Summarization
|
8 |
+
- **Description:** A fine-tuned T5-base model quantized to FP16 for generating concise summaries from short text inputs, guided by a user-specified keyword. Trained on a custom dataset of 200 examples, it produces summaries focusing on the keyword while maintaining a professional tone.
|
9 |
+
# Model Details
|
10 |
+
- **Architecture:** Encoder-Decoder Transformer (T5-base)
|
11 |
+
- **Parameters:** ~223M (original T5-base), quantized to FP16
|
12 |
+
- **Precision:** FP16 (16-bit floating-point)
|
13 |
+
- **Input Format:** Text paragraph + "Keyword: [keyword]" (e.g., "The storm caused heavy rain and wind damage. Keyword: rain")
|
14 |
+
- **Output Format:** Concise summary (1-2 sentences) focusing on the keyword (e.g., "The storm brought heavy rain overnight.")
|
15 |
+
- **Training Hardware:** NVIDIA GPU with 12 GB VRAM (e.g., RTX 3060)
|
16 |
+
- **Inference Hardware:** Compatible with GPUs supporting FP16 (minimum ~1.5 GB VRAM)
|
17 |
+
# Training Data
|
18 |
+
**Dataset Name:** Custom Keyword-Based Summarization Dataset
|
19 |
+
- **Size:** 200 examples
|
20 |
+
- **Split:** 180 training, 20 validation
|
21 |
+
- **Format:** CSV
|
22 |
+
- **input:** Paragraph (2-4 sentences) + "Keyword: [keyword]"
|
23 |
+
- **keyword:** Single word or short phrase guiding the summary
|
24 |
+
- **output:** Target summary (1-2 sentences)
|
25 |
+
- **Content:** Diverse topics including tech, weather, sports, health, and culture (e.g., "A new laptop was released with a fast processor... Keyword: processor" → "The new laptop has a fast processor.")
|
26 |
+
- **Language:** English
|
27 |
+
# Training Procedure
|
28 |
+
- **Framework:** PyTorch via Hugging Face Transformers
|
29 |
+
# Hyperparameters:
|
30 |
+
**Epochs:** 2 (stopped early; originally set for 3)
|
31 |
+
- **Learning Rate:** 3e-4
|
32 |
+
- **Batch Size:** 4 (effective 8 with gradient accumulation)
|
33 |
+
- **Warmup Steps:** 5
|
34 |
+
- **Weight Decay:** 0.01
|
35 |
+
- **Precision:** FP16 (mixed precision training)
|
36 |
+
- **Training Time:** ~1.5 minutes on a 12 GB GPU
|
37 |
+
# Loss:
|
38 |
+
- **Training:** 1.0099 (epoch 1) → 0.3479 (epoch 2)
|
39 |
+
- **Validation:** 1.0176 (epoch 1, best) → 1.0491 (epoch 2)
|
40 |
+
# Performance
|
41 |
+
- **Metrics:** Validation loss (best: 1.0176)
|
42 |
+
- **Qualitative Evaluation:** Generates concise, keyword-focused summaries with good coherence (e.g., "The concert featured a famous singer" for keyword "singer").
|
43 |
+
# Intended Use
|
44 |
+
- Purpose: Summarize short texts (e.g., news snippets, reports) based on a user-specified keyword.
|
45 |
+
- Use Case: Quick summarization for journalists, researchers, or content creators needing keyword-driven insights.
|
46 |
+
- Out of Scope: Not designed for long documents (>128 tokens) or abstractive summarization without keywords.
|
47 |
+
# Usage Instructions
|
48 |
+
```
|
49 |
+
Requirements
|
50 |
+
Python 3.8+
|
51 |
+
Libraries: transformers, torch, pandas
|
52 |
+
GPU with FP16 support (e.g., NVIDIA with ~1.5 GB VRAM free)
|
53 |
+
```
|
54 |
+
# Example Code
|
55 |
+
```python
|
56 |
+
|
57 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
58 |
+
|
59 |
+
# Load model and tokenizer
|
60 |
+
model = T5ForConditionalGeneration.from_pretrained("./t5_summary_finetuned_final_fp16").to("cuda")
|
61 |
+
tokenizer = T5Tokenizer.from_pretrained("./t5_summary_finetuned_final_fp16")
|
62 |
+
|
63 |
+
# Generate summary
|
64 |
+
text = "A new laptop was released with a fast processor and sleek design. It’s popular among gamers."
|
65 |
+
keyword = "processor"
|
66 |
+
input_text = f"{text} Keyword: {keyword}"
|
67 |
+
inputs = tokenizer(input_text, max_length=128, truncation=True, padding="max_length", return_tensors="pt").to("cuda")
|
68 |
+
outputs = model.generate(input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"].to(torch.float16), max_length=128, num_beams=4, early_stopping=True, no_repeat_ngram_size=2)
|
69 |
+
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
70 |
+
print(summary) # Expected: "The new laptop has a fast processor."
|
71 |
+
```
|