bge-reranker-base-int8-ov
Disclaimer: This model is provided for evaluation purposes only. Performance, accuracy, and stability may vary. Use at your own discretion.
- Model creator: BAAI
- Original model: bge-reranker-base
Description
This is bge-reranker-base model converted to the OpenVINO™ IR (Intermediate Representation) format with quantization to INT8 by NNCF.
Quantization Parameters
The quantization was performed using the next code:
from functools import partial
from transformers import AutoTokenizer
from optimum.intel import OVConfig, OVModelForSequenceClassification, OVQuantizationConfig, OVQuantizer
MODEL_ID = "OpenVINO/bge-reranker-base-fp16-ov"
base_model_path = "bge-reranker-base-fp16-ov"
int8_ptq_model_path = "bge-reranker-base-int8"
model = OVModelForSequenceClassification.from_pretrained(MODEL_ID)
model.save_pretrained(base_model_path)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
tokenizer.save_pretrained(base_model_path)
quantizer = OVQuantizer.from_pretrained(model)
def preprocess_function(examples, tokenizer):
return tokenizer(examples["sentence"], padding="max_length", max_length=384, truncation=True)
calibration_dataset = quantizer.get_calibration_dataset(
"glue",
dataset_config_name="sst2",
preprocess_function=partial(preprocess_function, tokenizer=tokenizer),
num_samples=300,
dataset_split="train",
)
ov_config = OVConfig(quantization_config=OVQuantizationConfig())
quantizer.quantize(ov_config=ov_config, calibration_dataset=calibration_dataset, save_directory=int8_ptq_model_path)
tokenizer.save_pretrained(int8_ptq_model_path)
For more information on quantization, check the OpenVINO model optimization guide.
Compatibility
The provided OpenVINO™ IR model is compatible with:
- OpenVINO version 2025.1.0 and higher
- Optimum Intel 1.24.0 and higher
Running Model Inference with Optimum Intel
- Install packages required for using Optimum Intel integration with the OpenVINO backend:
pip install optimum[openvino]
- Run model inference:
from transformers import AutoTokenizer
from optimum.intel import OVModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained('OpenVINO/bge-reranker-base-int8-ov')
model = OVModelForSequenceClassification.from_pretrained('OpenVINO/bge-reranker-base-int8-ov')
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.']]
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
print(scores)
For more examples and possible optimizations, refer to the Inference with Optimum Intel.
You can find more detailed usage examples in OpenVINO Notebooks:
Limitations
Check the original model card for limitations.
Legal information
The original model is distributed under MIT license. More details can be found in bge-reranker-base.
Disclaimer
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. 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.
- Downloads last month
- 54
Model tree for OpenVINO/bge-reranker-base-int8-ov
Base model
BAAI/bge-reranker-base