ReadMe
Browse files
README.md
CHANGED
|
@@ -1,65 +1,53 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
tags:
|
| 6 |
-
- generated_from_trainer
|
| 7 |
metrics:
|
| 8 |
- accuracy
|
| 9 |
-
model-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
| 15 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 16 |
-
|
| 17 |
-
# train-test
|
| 18 |
-
|
| 19 |
-
This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on an unknown dataset.
|
| 20 |
-
It achieves the following results on the evaluation set:
|
| 21 |
-
- Loss: 0.2701
|
| 22 |
-
- Accuracy: 0.9312
|
| 23 |
-
|
| 24 |
-
## Model description
|
| 25 |
-
|
| 26 |
-
More information needed
|
| 27 |
-
|
| 28 |
-
## Intended uses & limitations
|
| 29 |
-
|
| 30 |
-
More information needed
|
| 31 |
-
|
| 32 |
-
## Training and evaluation data
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
-
|
| 42 |
-
- train_batch_size: 4
|
| 43 |
-
- eval_batch_size: 8
|
| 44 |
-
- seed: 42
|
| 45 |
-
- gradient_accumulation_steps: 4
|
| 46 |
-
- total_train_batch_size: 16
|
| 47 |
-
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 48 |
-
- lr_scheduler_type: linear
|
| 49 |
-
- num_epochs: 2
|
| 50 |
-
- mixed_precision_training: Native AMP
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|:-------------:|:-----:|:----:|:---------------:|:--------:|
|
| 56 |
-
| 0.1761 | 1.0 | 4210 | 0.2282 | 0.9300 |
|
| 57 |
-
| 0.1127 | 2.0 | 8420 | 0.2701 | 0.9312 |
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
datasets:
|
| 4 |
+
- glue
|
|
|
|
|
|
|
| 5 |
metrics:
|
| 6 |
- accuracy
|
| 7 |
+
model-name: bert-base-uncased-finetuned-sst2
|
| 8 |
+
tags:
|
| 9 |
+
- text-classification
|
| 10 |
+
- sentiment-analysis
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# BERT Base (uncased) fine-tuned on SST-2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the **GLUE SST-2** dataset for sentiment classification (positive vs. negative).
|
| 16 |
|
| 17 |
+
## Model Details
|
| 18 |
+
- **Model type**: BERT (base, uncased)
|
| 19 |
+
- **Fine-tuned on**: SST-2 (Stanford Sentiment Treebank)
|
| 20 |
+
- **Labels**:
|
| 21 |
+
- 0 → Negative
|
| 22 |
+
- 1 → Positive
|
| 23 |
+
- **Training framework**: [🤗 Transformers](https://github.com/huggingface/transformers)
|
| 24 |
|
| 25 |
+
## Training
|
| 26 |
+
- Epochs: 2
|
| 27 |
+
- Batch size: 4 (with gradient accumulation steps = 4)
|
| 28 |
+
- Learning rate: 3e-5
|
| 29 |
+
- Mixed precision: fp16
|
| 30 |
+
- Optimizer & Scheduler: Default Hugging Face Trainer
|
| 31 |
|
| 32 |
+
## Evaluation Results
|
| 33 |
+
On the SST-2 validation set:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
| Epoch | Training Loss | Validation Loss | Accuracy |
|
| 36 |
+
|-------|---------------|-----------------|----------|
|
| 37 |
+
| 1 | 0.1761 | 0.2282 | 93.0% |
|
| 38 |
+
| 2 | 0.1127 | 0.2701 | 93.1% |
|
| 39 |
|
| 40 |
+
Final averaged training loss: **0.1663**
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
## How to Use
|
| 43 |
+
```python
|
| 44 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 45 |
|
| 46 |
+
model_name = "your-username/bert-base-uncased-finetuned-sst2"
|
| 47 |
+
tok = AutoTokenizer.from_pretrained(model_name)
|
| 48 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 49 |
|
| 50 |
+
inputs = tok("I love Hugging Face!", return_tensors="pt")
|
| 51 |
+
outputs = model(**inputs)
|
| 52 |
+
pred = outputs.logits.argmax(dim=-1).item()
|
| 53 |
+
print("Label:", pred) # 1 = Positive
|