File size: 1,316 Bytes
e1c3c09
 
c7c2381
 
 
 
 
 
 
 
e1c3c09
c7c2381
 
 
 
 
d56926a
c7c2381
 
 
 
 
 
 
b4d95a9
c7c2381
 
 
 
 
 
d56926a
c7c2381
 
bab0264
 
c7c2381
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
license: cc-by-4.0
tags:
- int8
- Intel® Neural Compressor
- PostTrainingStatic
datasets: 
- squad2
metrics:
- f1
---

# INT8 RoBERT base finetuned on Squad2

### Post-training static quantization

This is an INT8  PyTorch model quantized with [huggingface/optimum-intel](https://github.com/huggingface/optimum-intel) through the usage of [Intel® Neural Compressor](https://github.com/intel/neural-compressor). 

The original fp32 model comes from the fine-tuned model [deepset/roberta-base-squad2](https://huggingface.co/deepset/roberta-base-squad2).

The calibration dataloader is the train dataloader. The default calibration sampling size 100 isn't divisible exactly by batch size 8, so the real sampling size is 104.

The linear modules **roberta.encoder.layer.7.output.dense**, **roberta.encoder.layer.8.output.dense**, **roberta.encoder.layer.9.output.dense**, fall back to fp32 for less than 1% relative accuracy loss.

### Evaluation result

|   |INT8|FP32|
|---|:---:|:---:|
| **Accuracy (eval-f1)** |82.3122|82.9231|
| **Model size (MB)**  |141|474|

### Load with optimum:

```python
from optimum.intel.neural_compressor.quantization import IncQuantizedModelForQuestionAnswering
int8_model = IncQuantizedModelForQuestionAnswering.from_pretrained(
    'Intel/roberta-base-squad2-int8-static',
)
```