Upload folder using huggingface_hub
Browse files- README.md +124 -0
- config.json +33 -0
- openvino_config.json +24 -0
- openvino_model.bin +3 -0
- openvino_model.xml +0 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- vocab.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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-base-en-v1.5
|
| 8 |
+
---
|
| 9 |
+
# bge-base-en-v1.5-int8-ov
|
| 10 |
+
* Model creator: [BAAI](https://huggingface.co/BAAI)
|
| 11 |
+
* Original model: [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)
|
| 12 |
+
|
| 13 |
+
## Description
|
| 14 |
+
This is [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) 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 |
+
|
| 19 |
+
## Quantization Parameters
|
| 20 |
+
|
| 21 |
+
The quantization was performed using the next code:
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
from functools import partial
|
| 25 |
+
|
| 26 |
+
from transformers import AutoTokenizer
|
| 27 |
+
|
| 28 |
+
from optimum.intel import OVConfig, OVModelForFeatureExtraction, OVQuantizationConfig, OVQuantizer
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
MODEL_ID = "OpenVINO/bge-base-en-v1.5-fp16-ov"
|
| 32 |
+
base_model_path = "bge-base-en-v1.5"
|
| 33 |
+
int8_ptq_model_path = "bge-base-en-v1.5-int8"
|
| 34 |
+
|
| 35 |
+
model = OVModelForFeatureExtraction.from_pretrained(MODEL_ID)
|
| 36 |
+
model.save_pretrained(base_model_path)
|
| 37 |
+
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 39 |
+
tokenizer.save_pretrained(base_model_path)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
quantizer = OVQuantizer.from_pretrained(model)
|
| 43 |
+
|
| 44 |
+
def preprocess_function(examples, tokenizer):
|
| 45 |
+
return tokenizer(examples["sentence"], padding="max_length", max_length=384, truncation=True)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
calibration_dataset = quantizer.get_calibration_dataset(
|
| 49 |
+
"glue",
|
| 50 |
+
dataset_config_name="sst2",
|
| 51 |
+
preprocess_function=partial(preprocess_function, tokenizer=tokenizer),
|
| 52 |
+
num_samples=300,
|
| 53 |
+
dataset_split="train",
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
ov_config = OVConfig(quantization_config=OVQuantizationConfig())
|
| 57 |
+
|
| 58 |
+
quantizer.quantize(ov_config=ov_config, calibration_dataset=calibration_dataset, save_directory=int8_ptq_model_path)
|
| 59 |
+
tokenizer.save_pretrained(int8_ptq_model_path)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2024/openvino-workflow/model-optimization-guide/weight-compression.html).
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
## Compatibility
|
| 66 |
+
|
| 67 |
+
The provided OpenVINO™ IR model is compatible with:
|
| 68 |
+
|
| 69 |
+
* OpenVINO version 2025.1.0 and higher
|
| 70 |
+
* Optimum Intel 1.24.0 and higher
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
| 74 |
+
|
| 75 |
+
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
| 76 |
+
|
| 77 |
+
```
|
| 78 |
+
pip install "langchain-community>=0.2.15" optimum[openvino] huggingface_hub
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
2. Run model inference:
|
| 82 |
+
|
| 83 |
+
```
|
| 84 |
+
from langchain_community.embeddings import OpenVINOBgeEmbeddings
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
embedding_model_name = 'OpenVINO/bge-base-en-v1.5-int8-ov'
|
| 88 |
+
embedding_model_kwargs = {"device": "CPU", "compile": False}
|
| 89 |
+
encode_kwargs = {
|
| 90 |
+
"mean_pooling": False,
|
| 91 |
+
"normalize_embeddings": True,
|
| 92 |
+
"batch_size": 4,
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
embedding = OpenVINOBgeEmbeddings(
|
| 96 |
+
model_name_or_path=embedding_model_name,
|
| 97 |
+
model_kwargs=embedding_model_kwargs,
|
| 98 |
+
encode_kwargs=encode_kwargs,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
embedding.ov_model.compile()
|
| 102 |
+
|
| 103 |
+
text = "This is a test document."
|
| 104 |
+
embedding_result = embedding.embed_query(text)
|
| 105 |
+
embedding_result[:3]
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
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).
|
| 109 |
+
|
| 110 |
+
You can find more detailed usage examples in OpenVINO Notebooks:
|
| 111 |
+
|
| 112 |
+
- [RAG text generation](https://openvinotoolkit.github.io/openvino_notebooks/?search=RAG+system)
|
| 113 |
+
|
| 114 |
+
## Limitations
|
| 115 |
+
|
| 116 |
+
Check the original [model card](https://huggingface.co/BAAI/bge-base-en-v1.5) for limitations.
|
| 117 |
+
|
| 118 |
+
## Legal information
|
| 119 |
+
|
| 120 |
+
The original model is distributed under [MIT](https://github.com/FlagOpen/FlagEmbedding/blob/master/LICENSE) license. More details can be found in [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5).
|
| 121 |
+
|
| 122 |
+
## Disclaimer
|
| 123 |
+
|
| 124 |
+
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,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_attn_implementation_autoset": true,
|
| 3 |
+
"_name_or_path": "OpenVINO/bge-base-en-v1.5-fp16-ov",
|
| 4 |
+
"architectures": [
|
| 5 |
+
"BertModel"
|
| 6 |
+
],
|
| 7 |
+
"attention_probs_dropout_prob": 0.1,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"gradient_checkpointing": false,
|
| 10 |
+
"hidden_act": "gelu",
|
| 11 |
+
"hidden_dropout_prob": 0.1,
|
| 12 |
+
"hidden_size": 768,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0"
|
| 15 |
+
},
|
| 16 |
+
"initializer_range": 0.02,
|
| 17 |
+
"intermediate_size": 3072,
|
| 18 |
+
"label2id": {
|
| 19 |
+
"LABEL_0": 0
|
| 20 |
+
},
|
| 21 |
+
"layer_norm_eps": 1e-12,
|
| 22 |
+
"max_position_embeddings": 512,
|
| 23 |
+
"model_type": "bert",
|
| 24 |
+
"num_attention_heads": 12,
|
| 25 |
+
"num_hidden_layers": 12,
|
| 26 |
+
"pad_token_id": 0,
|
| 27 |
+
"position_embedding_type": "absolute",
|
| 28 |
+
"torch_dtype": "float32",
|
| 29 |
+
"transformers_version": "4.48.3",
|
| 30 |
+
"type_vocab_size": 2,
|
| 31 |
+
"use_cache": true,
|
| 32 |
+
"vocab_size": 30522
|
| 33 |
+
}
|
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:e93dee628b35680e54242ee38e96d5c6cd9d1e5ad8f065f0c4cc36c8744cf2fa
|
| 3 |
+
size 109974480
|
openvino_model.xml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": {
|
| 3 |
+
"content": "[CLS]",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"mask_token": {
|
| 10 |
+
"content": "[MASK]",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "[PAD]",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"sep_token": {
|
| 24 |
+
"content": "[SEP]",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"unk_token": {
|
| 31 |
+
"content": "[UNK]",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
}
|
| 37 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": true,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_basic_tokenize": true,
|
| 47 |
+
"do_lower_case": true,
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"model_max_length": 512,
|
| 51 |
+
"never_split": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"strip_accents": null,
|
| 55 |
+
"tokenize_chinese_chars": true,
|
| 56 |
+
"tokenizer_class": "BertTokenizer",
|
| 57 |
+
"unk_token": "[UNK]"
|
| 58 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|