Upload folder using huggingface_hub
Browse files- README.md +65 -0
- config.json +5 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +14 -0
- training_meta.json +13 -0
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: zero-shot-classification
|
| 7 |
+
tags:
|
| 8 |
+
- zero-shot
|
| 9 |
+
- multi-label
|
| 10 |
+
- text-classification
|
| 11 |
+
- pytorch
|
| 12 |
+
metrics:
|
| 13 |
+
- precision
|
| 14 |
+
- recall
|
| 15 |
+
- f1
|
| 16 |
+
base_model: bert-base-uncased
|
| 17 |
+
datasets:
|
| 18 |
+
- polodealvarado/zeroshot-classification
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Zero-Shot Text Classification — polyencoder
|
| 22 |
+
|
| 23 |
+
Learnable poly-codes with label-conditioned cross-attention.
|
| 24 |
+
|
| 25 |
+
This model encodes texts and candidate labels into a shared embedding space using BERT,
|
| 26 |
+
enabling classification into arbitrary categories without retraining for new labels.
|
| 27 |
+
|
| 28 |
+
## Training Details
|
| 29 |
+
|
| 30 |
+
| Parameter | Value |
|
| 31 |
+
|-----------|-------|
|
| 32 |
+
| Base model | `bert-base-uncased` |
|
| 33 |
+
| Model variant | `polyencoder` |
|
| 34 |
+
| Training steps | 1000 |
|
| 35 |
+
| Batch size | 2 |
|
| 36 |
+
| Learning rate | 2e-05 |
|
| 37 |
+
| Trainable params | 109,494,528 |
|
| 38 |
+
| Training time | 359.7s |
|
| 39 |
+
|
| 40 |
+
## Dataset
|
| 41 |
+
|
| 42 |
+
Trained on [polodealvarado/zeroshot-classification](https://huggingface.co/datasets/polodealvarado/zeroshot-classification).
|
| 43 |
+
|
| 44 |
+
## Evaluation Results
|
| 45 |
+
|
| 46 |
+
| Metric | Score |
|
| 47 |
+
|--------|-------|
|
| 48 |
+
| Precision | 0.9463 |
|
| 49 |
+
| Recall | 0.9677 |
|
| 50 |
+
| F1 Score | 0.9569 |
|
| 51 |
+
|
| 52 |
+
## Usage
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from models.polyencoder import PolyEncoderModel
|
| 56 |
+
|
| 57 |
+
model = PolyEncoderModel.from_pretrained("polodealvarado/polyencoder")
|
| 58 |
+
|
| 59 |
+
predictions = model.predict(
|
| 60 |
+
texts=["The stock market crashed yesterday."],
|
| 61 |
+
labels=[["Finance", "Sports", "Biology", "Economy"]],
|
| 62 |
+
)
|
| 63 |
+
print(predictions)
|
| 64 |
+
# [{"text": "...", "scores": {"Finance": 0.98, "Economy": 0.85, ...}}]
|
| 65 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_num_labels": 13,
|
| 3 |
+
"model_name": "bert-base-uncased",
|
| 4 |
+
"num_poly_codes": 16
|
| 5 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a101edbb3a5026b6de47b0f8b734e49c821c9de60771f764b5eda6b63f8c99ea
|
| 3 |
+
size 438003512
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_max_length": 512,
|
| 8 |
+
"pad_token": "[PAD]",
|
| 9 |
+
"sep_token": "[SEP]",
|
| 10 |
+
"strip_accents": null,
|
| 11 |
+
"tokenize_chinese_chars": true,
|
| 12 |
+
"tokenizer_class": "BertTokenizer",
|
| 13 |
+
"unk_token": "[UNK]"
|
| 14 |
+
}
|
training_meta.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "polyencoder",
|
| 3 |
+
"encoder_name": "bert-base-uncased",
|
| 4 |
+
"param_count": 109494528,
|
| 5 |
+
"num_steps": 1000,
|
| 6 |
+
"best_step": 950,
|
| 7 |
+
"batch_size": 2,
|
| 8 |
+
"learning_rate": 2e-05,
|
| 9 |
+
"train_time_s": 359.68,
|
| 10 |
+
"precision": 0.9463,
|
| 11 |
+
"recall": 0.9677,
|
| 12 |
+
"f1": 0.9569
|
| 13 |
+
}
|