Update README.md
Browse files
README.md
CHANGED
@@ -54,17 +54,40 @@ Precision Mode: FP16 for efficient training
|
|
54 |
|
55 |
### Test Set Performance:
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
|
61 |
-
|
|
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
|
|
66 |
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
### Test Set Performance:
|
56 |
|
57 |
+
| Metric | Score |
|
58 |
+
|---------------------|-------|
|
59 |
+
| SARI | 89.76 |
|
60 |
+
| SARI Penalized | 88.32 |
|
61 |
+
| ROUGE-1 | 93.14 |
|
62 |
+
| ROUGE-2 | 88.65 |
|
63 |
+
| ROUGE-L | 93.07 |
|
64 |
+
|
65 |
+
---
|
66 |
+
### Training Loss Curve
|
67 |
|
68 |
+
The loss curves during training are visualized in bart-large-sentence-compression_loss.eps, showing both training and evaluation loss over steps.
|
69 |
|
70 |
+
---
|
71 |
+
## **Usage**
|
72 |
|
73 |
+
### Load the Model
|
74 |
|
75 |
+
```python
|
76 |
+
from transformers import BartForConditionalGeneration, BartTokenizer
|
77 |
|
78 |
+
model_name = "shahin-as/bart-large-sentence-compression"
|
79 |
+
|
80 |
+
model = BartForConditionalGeneration.from_pretrained(model_name)
|
81 |
+
tokenizer = BartTokenizer.from_pretrained(model_name)
|
82 |
+
|
83 |
+
def compress_sentence(sentence):
|
84 |
+
inputs = tokenizer(sentence, return_tensors="pt", max_length=1024, truncation=True)
|
85 |
+
summary_ids = model.generate(**inputs, max_length=50, num_beams=5, length_penalty=2.0, early_stopping=True)
|
86 |
+
return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
87 |
|
88 |
+
# Example usage
|
89 |
+
sentence = "Insert the sentence to be compressed here."
|
90 |
+
compressed_sentence = compress_sentence(sentence)
|
91 |
+
print("Original:", sentence)
|
92 |
+
print("Compressed:", compressed_sentence)
|
93 |
+
```
|