Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +113 -0
- config.json +34 -0
- openvino_config.json +24 -0
- openvino_model.bin +3 -0
- openvino_model.xml +0 -0
- sentencepiece.bpe.model +3 -0
- special_tokens_map.json +51 -0
- tokenizer.json +3 -0
- tokenizer_config.json +56 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
license_link: https://github.com/FlagOpen/FlagEmbedding/blob/master/LICENSE
|
6 |
+
base_model:
|
7 |
+
- BAAI/bge-reranker-base
|
8 |
+
---
|
9 |
+
# bge-reranker-base-int8-ov
|
10 |
+
* Model creator: [BAAI](https://huggingface.co/BAAI)
|
11 |
+
* Original model: [bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base)
|
12 |
+
|
13 |
+
## Description
|
14 |
+
This is [bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2025/documentation/openvino-ir-format.html) (Intermediate Representation) format with quantization to INT8 by [NNCF](https://github.com/openvinotoolkit/nncf).
|
15 |
+
|
16 |
+
**Disclaimer**: Model is provided as a preview and may be update in the future.
|
17 |
+
|
18 |
+
## Quantization Parameters
|
19 |
+
|
20 |
+
The quantization was performed using the next code:
|
21 |
+
|
22 |
+
```
|
23 |
+
from functools import partial
|
24 |
+
|
25 |
+
from transformers import AutoTokenizer
|
26 |
+
|
27 |
+
from optimum.intel import OVConfig, OVModelForSequenceClassification, OVQuantizationConfig, OVQuantizer
|
28 |
+
|
29 |
+
|
30 |
+
MODEL_ID = "OpenVINO/bge-reranker-base-fp16-ov"
|
31 |
+
base_model_path = "bge-reranker-base-fp16-ov"
|
32 |
+
int8_ptq_model_path = "bge-reranker-base-int8"
|
33 |
+
|
34 |
+
model = OVModelForSequenceClassification.from_pretrained(MODEL_ID)
|
35 |
+
model.save_pretrained(base_model_path)
|
36 |
+
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
38 |
+
tokenizer.save_pretrained(base_model_path)
|
39 |
+
|
40 |
+
|
41 |
+
quantizer = OVQuantizer.from_pretrained(model)
|
42 |
+
|
43 |
+
def preprocess_function(examples, tokenizer):
|
44 |
+
return tokenizer(examples["sentence"], padding="max_length", max_length=384, truncation=True)
|
45 |
+
|
46 |
+
|
47 |
+
calibration_dataset = quantizer.get_calibration_dataset(
|
48 |
+
"glue",
|
49 |
+
dataset_config_name="sst2",
|
50 |
+
preprocess_function=partial(preprocess_function, tokenizer=tokenizer),
|
51 |
+
num_samples=300,
|
52 |
+
dataset_split="train",
|
53 |
+
)
|
54 |
+
|
55 |
+
ov_config = OVConfig(quantization_config=OVQuantizationConfig())
|
56 |
+
|
57 |
+
quantizer.quantize(ov_config=ov_config, calibration_dataset=calibration_dataset, save_directory=int8_ptq_model_path)
|
58 |
+
tokenizer.save_pretrained(int8_ptq_model_path)
|
59 |
+
```
|
60 |
+
|
61 |
+
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2025/openvino-workflow/model-optimization-guide/quantizing-models-post-training.html).
|
62 |
+
|
63 |
+
|
64 |
+
## Compatibility
|
65 |
+
|
66 |
+
The provided OpenVINO™ IR model is compatible with:
|
67 |
+
|
68 |
+
* OpenVINO version 2025.1.0 and higher
|
69 |
+
* Optimum Intel 1.24.0 and higher
|
70 |
+
|
71 |
+
|
72 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
73 |
+
|
74 |
+
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
75 |
+
|
76 |
+
```
|
77 |
+
pip install optimum[openvino]
|
78 |
+
```
|
79 |
+
|
80 |
+
2. Run model inference:
|
81 |
+
|
82 |
+
```
|
83 |
+
from transformers import AutoTokenizer
|
84 |
+
from optimum.intel import OVModelForSequenceClassification
|
85 |
+
|
86 |
+
|
87 |
+
tokenizer = AutoTokenizer.from_pretrained('OpenVINO/bge-reranker-base-int8-ov')
|
88 |
+
model = OVModelForSequenceClassification.from_pretrained('OpenVINO/bge-reranker-base-int8-ov')
|
89 |
+
|
90 |
+
pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']]
|
91 |
+
|
92 |
+
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
|
93 |
+
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
|
94 |
+
print(scores)
|
95 |
+
```
|
96 |
+
|
97 |
+
For more examples and possible optimizations, refer to the [Inference with Optimum Intel](https://docs.openvino.ai/2025/openvino-workflow-generative/inference-with-optimum-intel.html).
|
98 |
+
|
99 |
+
You can find more detailed usage examples in OpenVINO Notebooks:
|
100 |
+
|
101 |
+
- [RAG text generation](https://openvinotoolkit.github.io/openvino_notebooks/?search=RAG+system)
|
102 |
+
|
103 |
+
## Limitations
|
104 |
+
|
105 |
+
Check the original [model card](https://huggingface.co/BAAI/bge-reranker-base) for limitations.
|
106 |
+
|
107 |
+
## Legal information
|
108 |
+
|
109 |
+
The original model is distributed under [MIT](https://github.com/FlagOpen/FlagEmbedding/blob/master/LICENSE) license. More details can be found in [bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base).
|
110 |
+
|
111 |
+
## Disclaimer
|
112 |
+
|
113 |
+
Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See [Intel’s Global Human Rights Principles](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/policy-human-rights.pdf). Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights.
|
config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_attn_implementation_autoset": true,
|
3 |
+
"_name_or_path": "OpenVINO/bge-reranker-base-fp16-ov",
|
4 |
+
"architectures": [
|
5 |
+
"XLMRobertaForSequenceClassification"
|
6 |
+
],
|
7 |
+
"attention_probs_dropout_prob": 0.1,
|
8 |
+
"bos_token_id": 0,
|
9 |
+
"classifier_dropout": null,
|
10 |
+
"eos_token_id": 2,
|
11 |
+
"hidden_act": "gelu",
|
12 |
+
"hidden_dropout_prob": 0.1,
|
13 |
+
"hidden_size": 768,
|
14 |
+
"id2label": {
|
15 |
+
"0": "LABEL_0"
|
16 |
+
},
|
17 |
+
"initializer_range": 0.02,
|
18 |
+
"intermediate_size": 3072,
|
19 |
+
"label2id": {
|
20 |
+
"LABEL_0": 0
|
21 |
+
},
|
22 |
+
"layer_norm_eps": 1e-05,
|
23 |
+
"max_position_embeddings": 514,
|
24 |
+
"model_type": "xlm-roberta",
|
25 |
+
"num_attention_heads": 12,
|
26 |
+
"num_hidden_layers": 12,
|
27 |
+
"output_past": true,
|
28 |
+
"pad_token_id": 1,
|
29 |
+
"position_embedding_type": "absolute",
|
30 |
+
"transformers_version": "4.48.3",
|
31 |
+
"type_vocab_size": 1,
|
32 |
+
"use_cache": true,
|
33 |
+
"vocab_size": 250002
|
34 |
+
}
|
openvino_config.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compression": null,
|
3 |
+
"dtype": "int8",
|
4 |
+
"input_info": null,
|
5 |
+
"optimum_version": "1.24.0",
|
6 |
+
"quantization_config": {
|
7 |
+
"activation_format": "int8",
|
8 |
+
"bits": 8,
|
9 |
+
"dataset": null,
|
10 |
+
"fast_bias_correction": true,
|
11 |
+
"ignored_scope": null,
|
12 |
+
"model_type": "transformer",
|
13 |
+
"num_samples": 300,
|
14 |
+
"overflow_fix": "disable",
|
15 |
+
"processor": null,
|
16 |
+
"smooth_quant_alpha": null,
|
17 |
+
"sym": false,
|
18 |
+
"tokenizer": null,
|
19 |
+
"trust_remote_code": false,
|
20 |
+
"weight_format": "int8"
|
21 |
+
},
|
22 |
+
"save_onnx_model": false,
|
23 |
+
"transformers_version": "4.48.3"
|
24 |
+
}
|
openvino_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6dcc0aa449397a94037eab006108cfb03f8cb77745d87fbfe7601e4f20d3ee38
|
3 |
+
size 280016732
|
openvino_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|
sentencepiece.bpe.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
|
3 |
+
size 5069051
|
special_tokens_map.json
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": {
|
10 |
+
"content": "<s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"eos_token": {
|
17 |
+
"content": "</s>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"mask_token": {
|
24 |
+
"content": "<mask>",
|
25 |
+
"lstrip": true,
|
26 |
+
"normalized": true,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"pad_token": {
|
31 |
+
"content": "<pad>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"sep_token": {
|
38 |
+
"content": "</s>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false
|
43 |
+
},
|
44 |
+
"unk_token": {
|
45 |
+
"content": "<unk>",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": false,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false
|
50 |
+
}
|
51 |
+
}
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6465c7619e715f898f06ed509f45338b915939321afa048f48a7c8ac9ee875a0
|
3 |
+
size 17083063
|
tokenizer_config.json
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<s>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<pad>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "</s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"3": {
|
28 |
+
"content": "<unk>",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"250001": {
|
36 |
+
"content": "<mask>",
|
37 |
+
"lstrip": true,
|
38 |
+
"normalized": true,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"bos_token": "<s>",
|
45 |
+
"clean_up_tokenization_spaces": true,
|
46 |
+
"cls_token": "<s>",
|
47 |
+
"eos_token": "</s>",
|
48 |
+
"extra_special_tokens": {},
|
49 |
+
"mask_token": "<mask>",
|
50 |
+
"model_max_length": 512,
|
51 |
+
"pad_token": "<pad>",
|
52 |
+
"sep_token": "</s>",
|
53 |
+
"sp_model_kwargs": {},
|
54 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
55 |
+
"unk_token": "<unk>"
|
56 |
+
}
|