lrodrigues
commited on
Commit
•
c39c03b
1
Parent(s):
7b1992c
upload
Browse files- README.md +52 -0
- config.json +48 -0
- flax_model.msgpack +3 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +3 -0
- vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- multi_nli
|
4 |
+
language: en
|
5 |
+
license: mit
|
6 |
+
pipeline_tag: zero-shot-classification
|
7 |
+
tags:
|
8 |
+
- bart
|
9 |
+
- zero-shot-classification
|
10 |
+
---
|
11 |
+
# Bart large model for NLI-based Zero Shot Text Classification
|
12 |
+
|
13 |
+
This model uses [bart-large](https://huggingface.co/facebook/bart-large).
|
14 |
+
|
15 |
+
## Training Data
|
16 |
+
This model was trained on the [MultiNLI (MNLI)](https://huggingface.co/datasets/multi_nli) dataset in the manner originally described in [Yin et al. 2019](https://arxiv.org/abs/1909.00161).
|
17 |
+
|
18 |
+
It can be used to predict whether a topic label can be assigned to a given sequence, whether or not the label has been seen before.
|
19 |
+
|
20 |
+
## Usage and Performance
|
21 |
+
The trained model can be used like this:
|
22 |
+
```python
|
23 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
24 |
+
|
25 |
+
# Load model & tokenizer
|
26 |
+
bart_model = AutoModelForSequenceClassification.from_pretrained('navteca/bart-large-mnli')
|
27 |
+
bart_tokenizer = AutoTokenizer.from_pretrained('navteca/bart-large-mnli')
|
28 |
+
|
29 |
+
# Get predictions
|
30 |
+
nlp = pipeline('zero-shot-classification', model=bart_model, tokenizer=bart_tokenizer)
|
31 |
+
|
32 |
+
sequence = 'One day I will see the world.'
|
33 |
+
candidate_labels = ['cooking', 'dancing', 'travel']
|
34 |
+
|
35 |
+
result = nlp(sequence, candidate_labels, multi_label=True)
|
36 |
+
|
37 |
+
print(result)
|
38 |
+
|
39 |
+
#{
|
40 |
+
# "sequence": "One day I will see the world.",
|
41 |
+
# "labels": [
|
42 |
+
# "travel",
|
43 |
+
# "dancing",
|
44 |
+
# "cooking"
|
45 |
+
# ],
|
46 |
+
# "scores": [
|
47 |
+
# 0.9941897988319397,
|
48 |
+
# 0.0060537424869835,
|
49 |
+
# 0.0020010927692056
|
50 |
+
# ]
|
51 |
+
#}
|
52 |
+
```
|
config.json
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_num_labels": 3,
|
3 |
+
"activation_dropout": 0,
|
4 |
+
"activation_function": "gelu",
|
5 |
+
"add_final_layer_norm": false,
|
6 |
+
"architectures": [
|
7 |
+
"BartForSequenceClassification"
|
8 |
+
],
|
9 |
+
"attention_dropout": 0,
|
10 |
+
"bos_token_id": 0,
|
11 |
+
"classif_dropout": 0,
|
12 |
+
"classifier_dropout": 0,
|
13 |
+
"d_model": 1024,
|
14 |
+
"decoder_attention_heads": 16,
|
15 |
+
"decoder_ffn_dim": 4096,
|
16 |
+
"decoder_layerdrop": 0,
|
17 |
+
"decoder_layers": 12,
|
18 |
+
"decoder_start_token_id": 2,
|
19 |
+
"dropout": 0.1,
|
20 |
+
"encoder_attention_heads": 16,
|
21 |
+
"encoder_ffn_dim": 4096,
|
22 |
+
"encoder_layerdrop": 0,
|
23 |
+
"encoder_layers": 12,
|
24 |
+
"eos_token_id": 2,
|
25 |
+
"forced_eos_token_id": 2,
|
26 |
+
"gradient_checkpointing": false,
|
27 |
+
"id2label": {
|
28 |
+
"0": "contradiction",
|
29 |
+
"1": "neutral",
|
30 |
+
"2": "entailment"
|
31 |
+
},
|
32 |
+
"init_std": 0.02,
|
33 |
+
"is_encoder_decoder": true,
|
34 |
+
"label2id": {
|
35 |
+
"contradiction": 0,
|
36 |
+
"neutral": 1,
|
37 |
+
"entailment": 2
|
38 |
+
},
|
39 |
+
"max_position_embeddings": 1024,
|
40 |
+
"model_type": "bart",
|
41 |
+
"normalize_before": false,
|
42 |
+
"num_hidden_layers": 12,
|
43 |
+
"output_past": false,
|
44 |
+
"pad_token_id": 1,
|
45 |
+
"scale_embedding": false,
|
46 |
+
"use_cache": true,
|
47 |
+
"vocab_size": 50265
|
48 |
+
}
|
flax_model.msgpack
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5e07d1ae73ae1c1267fd174a3b21c73b0d77bad288f8ed17fb685f79c419a897
|
3 |
+
size 1629394629
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ce253627f98f9db22af6a86efee6e905f001f7d8dc02dd14a8b4b4710c302b17
|
3 |
+
size 1629486723
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_max_length": 1024
|
3 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|