Commit
·
2929a1f
1
Parent(s):
b2d9803
Update README.md
Browse files
README.md
CHANGED
|
@@ -73,106 +73,29 @@ Users (both direct and downstream) should be made aware of the risks, biases and
|
|
| 73 |
|
| 74 |
Use the code below to get started with the model.
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 100 |
-
|
| 101 |
-
#### Speeds, Sizes, Times [optional]
|
| 102 |
-
|
| 103 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 104 |
-
|
| 105 |
-
[More Information Needed]
|
| 106 |
-
|
| 107 |
-
## Evaluation
|
| 108 |
-
|
| 109 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 110 |
-
|
| 111 |
-
See the **Evaluation Results** section of our paper.
|
| 112 |
-
|
| 113 |
-
### Testing Data, Factors & Metrics
|
| 114 |
-
|
| 115 |
-
#### Testing Data
|
| 116 |
-
|
| 117 |
-
<!-- This should link to a Data Card if possible. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Factors
|
| 122 |
-
|
| 123 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
#### Metrics
|
| 128 |
-
|
| 129 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 130 |
-
|
| 131 |
-
[More Information Needed]
|
| 132 |
-
|
| 133 |
-
### Results
|
| 134 |
-
|
| 135 |
-
[More Information Needed]
|
| 136 |
-
|
| 137 |
-
#### Summary
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
## Model Examination [optional]
|
| 142 |
-
|
| 143 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 144 |
-
|
| 145 |
-
[More Information Needed]
|
| 146 |
-
|
| 147 |
-
## Environmental Impact
|
| 148 |
-
|
| 149 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 150 |
-
|
| 151 |
-
<!-- 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). -->
|
| 152 |
-
|
| 153 |
-
- **Hardware Type:**
|
| 154 |
-
- **Hours used:**
|
| 155 |
-
- **Cloud Provider:**
|
| 156 |
-
- **Compute Region:**
|
| 157 |
-
- **Carbon Emitted:**
|
| 158 |
-
|
| 159 |
-
## Technical Specifications [optional]
|
| 160 |
-
|
| 161 |
-
### Model Architecture and Objective
|
| 162 |
-
|
| 163 |
-
[More Information Needed]
|
| 164 |
-
|
| 165 |
-
### Compute Infrastructure
|
| 166 |
-
|
| 167 |
-
[More Information Needed]
|
| 168 |
-
|
| 169 |
-
#### Hardware
|
| 170 |
-
|
| 171 |
-
[More Information Needed]
|
| 172 |
-
|
| 173 |
-
#### Software
|
| 174 |
-
|
| 175 |
-
[More Information Needed]
|
| 176 |
|
| 177 |
## Citation [optional]
|
| 178 |
|
|
@@ -180,25 +103,15 @@ See the **Evaluation Results** section of our paper.
|
|
| 180 |
|
| 181 |
**BibTeX:**
|
| 182 |
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
[More Information Needed]
|
| 194 |
-
|
| 195 |
-
## More Information [optional]
|
| 196 |
-
|
| 197 |
-
[More Information Needed]
|
| 198 |
-
|
| 199 |
-
## Model Card Authors [optional]
|
| 200 |
-
|
| 201 |
-
[More Information Needed]
|
| 202 |
|
| 203 |
## Model Card Contact
|
| 204 |
|
|
|
|
| 73 |
|
| 74 |
Use the code below to get started with the model.
|
| 75 |
|
| 76 |
+
```python
|
| 77 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained('liujch1998/vera')
|
| 78 |
+
model = transformers.T5EncoderModel.from_pretrained('liujch1998/vera')
|
| 79 |
+
model.D = model.shared.embedding_dim
|
| 80 |
+
linear = torch.nn.Linear(model.D, 1, dtype=model.dtype)
|
| 81 |
+
linear.weight = torch.nn.Parameter(model.shared.weight[32099, :].unsqueeze(0))
|
| 82 |
+
linear.bias = torch.nn.Parameter(model.shared.weight[32098, 0].unsqueeze(0))
|
| 83 |
+
model.eval()
|
| 84 |
+
t = model.shared.weight[32097, 0].item() # temperature for calibration
|
| 85 |
+
|
| 86 |
+
statement = 'Please enter a commonsense statement here.'
|
| 87 |
+
input_ids = tokenizer.batch_encode_plus([statement], return_tensors='pt', padding='longest', truncation='longest_first', max_length=128).input_ids
|
| 88 |
+
with torch.no_grad():
|
| 89 |
+
output = model(input_ids)
|
| 90 |
+
last_hidden_state = output.last_hidden_state
|
| 91 |
+
hidden = last_hidden_state[0, -1, :]
|
| 92 |
+
logit = linear(hidden).squeeze(-1)
|
| 93 |
+
logit_calibrated = logit / t
|
| 94 |
+
score_calibrated = logit_calibrated.sigmoid()
|
| 95 |
+
# score_calibrated is Vera's final output plausibility score
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
You may also refer to <https://huggingface.co/spaces/liujch1998/vera/blob/main/app.py#L27-L98> for implementation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
## Citation [optional]
|
| 101 |
|
|
|
|
| 103 |
|
| 104 |
**BibTeX:**
|
| 105 |
|
| 106 |
+
```
|
| 107 |
+
@article{Liu2023VeraAG,
|
| 108 |
+
title={Vera: A General-Purpose Plausibility Estimation Model for Commonsense Statements},
|
| 109 |
+
author={Jiacheng Liu and Wenya Wang and Dianzhuo Wang and Noah A. Smith and Yejin Choi and Hanna Hajishirzi},
|
| 110 |
+
journal={ArXiv},
|
| 111 |
+
year={2023},
|
| 112 |
+
volume={abs/2305.03695}
|
| 113 |
+
}
|
| 114 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
## Model Card Contact
|
| 117 |
|