mkdir -p ${HOME}/models
export GPU_ARGS=$(if ls /dev/dri/render* >/dev/null 2>&1; then echo "--device /dev/dri --group-add $(stat -c '%g' /dev/dri/render* | head -n1)"; fi)
docker run -d ${GPU_ARGS} --user $(id -u):$(id -g) --rm -p 8000:8000 -v ${HOME}/models:/models openvino/model_server:latest-gpu \
--rest_port 8000 --model_repository_path /models --source_model OpenVINO/bge-base-en-v1.5-fp16-ov
2. Install the client library:
pip install openai "numpy<2"
3. Run the client:
from openai import OpenAI
import numpy as np
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="unused"
)
model = "OpenVINO/bge-base-en-v1.5-fp16-ov"
embedding_responses = client.embeddings.create(
input=[
"That is a happy person",
"That is a very happy person"
],
model=model,
)
embedding_from_string1 = np.array(embedding_responses.data[0].embedding)
embedding_from_string2 = np.array(embedding_responses.data[1].embedding)
cos_sim = np.dot(embedding_from_string1, embedding_from_string2)/(np.linalg.norm(embedding_from_string1)*np.linalg.norm(embedding_from_string2))
print("Similarity score as cos_sim", cos_sim)
## Limitations
Check the original [model card](https://huggingface.co/BAAI/bge-base-en-v1.5) for limitations.
## Legal information
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).
## 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](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.