Add model card
Browse files
README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
tags:
|
| 6 |
+
- summarization
|
| 7 |
+
- text2text-generation
|
| 8 |
+
- switch-transformer
|
| 9 |
+
- mixture-of-experts
|
| 10 |
+
- pytorch
|
| 11 |
+
pipeline_tag: summarization
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Switch Transformers — Dialogue Summarization
|
| 15 |
+
|
| 16 |
+
A Switch Transformer (Mixture-of-Experts T5) model fine-tuned for abstractive text summarization. The model uses sparse expert routing to scale model capacity without a proportional increase in compute per token.
|
| 17 |
+
|
| 18 |
+
## Model Description
|
| 19 |
+
|
| 20 |
+
Switch Transformers replace the dense feed-forward sublayers in standard T5 with Mixture-of-Experts (MoE) layers. Each token is routed to one of `num_experts=8` expert feed-forward networks by a learned routing function, allowing the model to specialize different experts for different types of input. This repo contains a fine-tuned variant configured for summarization.
|
| 21 |
+
|
| 22 |
+
| Parameter | Value |
|
| 23 |
+
|---|---|
|
| 24 |
+
| Architecture | SwitchTransformersForConditionalGeneration |
|
| 25 |
+
| Number of experts | 8 |
|
| 26 |
+
| Task | Conditional text generation / summarization |
|
| 27 |
+
| Format | Safetensors |
|
| 28 |
+
|
| 29 |
+
## How to Use
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 33 |
+
|
| 34 |
+
tokenizer = AutoTokenizer.from_pretrained("YashNagraj75/SwitchTransformers-Summarization/switch-transformer-tokenizer")
|
| 35 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("YashNagraj75/SwitchTransformers-Summarization/switch-transformer")
|
| 36 |
+
|
| 37 |
+
text = "Your long document or conversation here..."
|
| 38 |
+
inputs = tokenizer("summarize: " + text, return_tensors="pt", truncation=True)
|
| 39 |
+
outputs = model.generate(
|
| 40 |
+
**inputs,
|
| 41 |
+
max_length=200,
|
| 42 |
+
min_length=30,
|
| 43 |
+
num_beams=4,
|
| 44 |
+
length_penalty=2.0,
|
| 45 |
+
no_repeat_ngram_size=3,
|
| 46 |
+
early_stopping=True,
|
| 47 |
+
)
|
| 48 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Generation Config
|
| 52 |
+
|
| 53 |
+
| Parameter | Value |
|
| 54 |
+
|---|---|
|
| 55 |
+
| Prefix | `summarize: ` |
|
| 56 |
+
| Max length | 200 |
|
| 57 |
+
| Min length | 30 |
|
| 58 |
+
| Num beams | 4 |
|
| 59 |
+
| Length penalty | 2.0 |
|
| 60 |
+
| No repeat ngram size | 3 |
|
| 61 |
+
| Early stopping | True |
|
| 62 |
+
|
| 63 |
+
## Repository Contents
|
| 64 |
+
|
| 65 |
+
| Path | Description |
|
| 66 |
+
|---|---|
|
| 67 |
+
| switch-T5.ipynb | Training and evaluation notebook |
|
| 68 |
+
| switch-transformer/ | Model weights (safetensors) + config |
|
| 69 |
+
| switch-transformer-tokenizer/ | Tokenizer files |
|
| 70 |
+
|
| 71 |
+
## License
|
| 72 |
+
|
| 73 |
+
MIT
|