update readme
Browse files
README.md
CHANGED
@@ -1,200 +1,78 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
3 |
tags:
|
4 |
- cross-encoder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
-
# Model Card for Model ID
|
8 |
|
9 |
-
|
|
|
|
|
10 |
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
##
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
- **Shared by [optional]:** [More Information Needed]
|
24 |
-
- **Model type:** [More Information Needed]
|
25 |
-
- **Language(s) (NLP):** [More Information Needed]
|
26 |
-
- **License:** [More Information Needed]
|
27 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
-
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
[More Information Needed]
|
46 |
-
|
47 |
-
### Downstream Use [optional]
|
48 |
-
|
49 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
50 |
-
|
51 |
-
[More Information Needed]
|
52 |
-
|
53 |
-
### Out-of-Scope Use
|
54 |
-
|
55 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
56 |
-
|
57 |
-
[More Information Needed]
|
58 |
-
|
59 |
-
## Bias, Risks, and Limitations
|
60 |
-
|
61 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
62 |
-
|
63 |
-
[More Information Needed]
|
64 |
-
|
65 |
-
### Recommendations
|
66 |
-
|
67 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
68 |
-
|
69 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
70 |
-
|
71 |
-
## How to Get Started with the Model
|
72 |
-
|
73 |
-
Use the code below to get started with the model.
|
74 |
-
|
75 |
-
[More Information Needed]
|
76 |
-
|
77 |
-
## Training Details
|
78 |
-
|
79 |
-
### Training Data
|
80 |
-
|
81 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
82 |
-
|
83 |
-
[More Information Needed]
|
84 |
-
|
85 |
-
### Training Procedure
|
86 |
-
|
87 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
88 |
-
|
89 |
-
#### Preprocessing [optional]
|
90 |
-
|
91 |
-
[More Information Needed]
|
92 |
-
|
93 |
-
|
94 |
-
#### Training Hyperparameters
|
95 |
-
|
96 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
97 |
-
|
98 |
-
#### Speeds, Sizes, Times [optional]
|
99 |
-
|
100 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
101 |
-
|
102 |
-
[More Information Needed]
|
103 |
-
|
104 |
-
## Evaluation
|
105 |
-
|
106 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
107 |
-
|
108 |
-
### Testing Data, Factors & Metrics
|
109 |
-
|
110 |
-
#### Testing Data
|
111 |
-
|
112 |
-
<!-- This should link to a Dataset Card if possible. -->
|
113 |
-
|
114 |
-
[More Information Needed]
|
115 |
-
|
116 |
-
#### Factors
|
117 |
-
|
118 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
119 |
-
|
120 |
-
[More Information Needed]
|
121 |
-
|
122 |
-
#### Metrics
|
123 |
-
|
124 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
125 |
-
|
126 |
-
[More Information Needed]
|
127 |
-
|
128 |
-
### Results
|
129 |
-
|
130 |
-
[More Information Needed]
|
131 |
-
|
132 |
-
#### Summary
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
## Model Examination [optional]
|
137 |
-
|
138 |
-
<!-- Relevant interpretability work for the model goes here -->
|
139 |
-
|
140 |
-
[More Information Needed]
|
141 |
-
|
142 |
-
## Environmental Impact
|
143 |
-
|
144 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
145 |
-
|
146 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
147 |
-
|
148 |
-
- **Hardware Type:** [More Information Needed]
|
149 |
-
- **Hours used:** [More Information Needed]
|
150 |
-
- **Cloud Provider:** [More Information Needed]
|
151 |
-
- **Compute Region:** [More Information Needed]
|
152 |
-
- **Carbon Emitted:** [More Information Needed]
|
153 |
-
|
154 |
-
## Technical Specifications [optional]
|
155 |
-
|
156 |
-
### Model Architecture and Objective
|
157 |
-
|
158 |
-
[More Information Needed]
|
159 |
-
|
160 |
-
### Compute Infrastructure
|
161 |
-
|
162 |
-
[More Information Needed]
|
163 |
-
|
164 |
-
#### Hardware
|
165 |
-
|
166 |
-
[More Information Needed]
|
167 |
-
|
168 |
-
#### Software
|
169 |
-
|
170 |
-
[More Information Needed]
|
171 |
-
|
172 |
-
## Citation [optional]
|
173 |
-
|
174 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
175 |
-
|
176 |
-
**BibTeX:**
|
177 |
-
|
178 |
-
[More Information Needed]
|
179 |
-
|
180 |
-
**APA:**
|
181 |
-
|
182 |
-
[More Information Needed]
|
183 |
-
|
184 |
-
## Glossary [optional]
|
185 |
-
|
186 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
187 |
-
|
188 |
-
[More Information Needed]
|
189 |
-
|
190 |
-
## More Information [optional]
|
191 |
-
|
192 |
-
[More Information Needed]
|
193 |
-
|
194 |
-
## Model Card Authors [optional]
|
195 |
-
|
196 |
-
[More Information Needed]
|
197 |
-
|
198 |
-
## Model Card Contact
|
199 |
-
|
200 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
license: cc-by-sa-4.0
|
3 |
+
language: ja
|
4 |
+
pipeline_tag: zero-shot-classification
|
5 |
+
library_name: sentence-transformers
|
6 |
tags:
|
7 |
- cross-encoder
|
8 |
+
- tohoku-nlp/bert-base-japanese-v3
|
9 |
+
- nli
|
10 |
+
- natural-language-inference
|
11 |
+
datasets:
|
12 |
+
- shunk031/jsnli
|
13 |
+
- hpprc/jsick
|
14 |
+
- shunk031/JGLUE
|
15 |
---
|
16 |
|
|
|
17 |
|
18 |
+
# Cross-Encoder for Natural Language Inference(NLI) for Japanese
|
19 |
+
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
|
20 |
+
This model is based on [tohoku-nlp/bert-base-japanese-v3](https://huggingface.co/tohoku-nlp/bert-base-japanese-v3).
|
21 |
|
22 |
+
## Training Data
|
23 |
+
The model was trained on following datasets.
|
24 |
|
25 |
+
- [JSNLI](https://nlp.ist.i.kyoto-u.ac.jp/?%E6%97%A5%E6%9C%AC%E8%AA%9ESNLI%28JSNLI%29%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BB%E3%83%83%E3%83%88)
|
26 |
+
- [JNLI](https://github.com/yahoojapan/JGLUE) (only train set)
|
27 |
+
- [JSICK](https://github.com/verypluming/JSICK) (only train set)
|
28 |
+
-
|
29 |
+
For a given sentence pair, it will output three scores corresponding to the labels: {0:"entailment", 1:"neutral", 2:"contradiction}.
|
30 |
|
31 |
+
## Usage
|
32 |
|
33 |
+
Pre-trained models can be used like this:
|
34 |
+
```python
|
35 |
+
from sentence_transformers import CrossEncoder
|
36 |
+
model = CrossEncoder('akiFQC/bert-base-japanese-v3_nli-jsnli')
|
37 |
+
scores = model.predict([('男はピザを食べています', '男は何かを食べています'), ('黒いレーシングカーが観衆の前から発車します。', '男は誰もいない道を運転しています。')])
|
38 |
|
39 |
+
#Convert scores to labels
|
40 |
+
label_mapping = ['entailment', 'neutral', 'contradiction',]
|
41 |
+
labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
|
42 |
+
```
|
43 |
|
44 |
+
## Usage with Transformers AutoModel
|
45 |
+
You can use the model also directly with Transformers library (without SentenceTransformers library):
|
46 |
+
```python
|
47 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
48 |
+
import torch
|
49 |
|
50 |
+
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/nli-deberta-v3-base')
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-deberta-v3-base')
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
features = tokenizer(['男はピザを食べています', '黒いレーシングカーが観衆の前から発車します。'], ['男は何かを食べています', '男は誰もいない道を運転しています。'], padding=True, truncation=True, return_tensors="pt")
|
54 |
|
55 |
+
model.eval()
|
56 |
+
with torch.no_grad():
|
57 |
+
scores = model(**features).logits
|
58 |
+
label_mapping = ['contradiction', 'entailment', 'neutral']
|
59 |
+
labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
|
60 |
+
print(labels)
|
61 |
+
```
|
62 |
|
63 |
+
## Zero-Shot Classification
|
64 |
+
This model can also be used for zero-shot-classification:
|
65 |
+
```python
|
66 |
+
from transformers import pipeline
|
67 |
|
68 |
+
classifier = pipeline("zero-shot-classification", model='akiFQC/bert-base-japanese-v3_nli-jsnli')
|
69 |
|
70 |
+
sent = "Appleは先程、iPhoneの最新機種について発表しました。"
|
71 |
+
candidate_labels = ["技術", "スポーツ", "政治"]
|
72 |
+
res = classifier(sent, candidate_labels)
|
73 |
+
print(res)
|
74 |
+
```
|
75 |
|
76 |
+
## Benchmarks
|
77 |
|
78 |
+
[JGLUE-JNLI](https://github.com/yahoojapan/JGLUE) validation set accuracy: 0.914
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|