hotchpotch / vespa-onnx-intfloat-multilingual-e5-small

huggingface.co
Total runs: 12
24-hour runs: 0
7-day runs: 1
30-day runs: 5
Model's Last Updated: Tháng tư 04 2024
feature-extraction

Introduction of vespa-onnx-intfloat-multilingual-e5-small

Model Details of vespa-onnx-intfloat-multilingual-e5-small

Converted intfloat/multilingual-e5-small model in onnx format for use with Vespa Embedding .

  • intfloat-multilingual-e5-small.onnx
  • intfloat-multilingual-e5-small_fp16.onnx
  • intfloat-multilingual-e5-small_quantized.onnx
    • (int8 quantize, In python, running it produces a different result...)

python can also output the same vectors as vespa's embeddings.

Note: normalize must be set to true in vespa's service.xml in order for embeddings output to be the same as python.

<component id="me5_small_q" type="hugging-face-embedder">
    <transformer-model path="me5/intfloat-multilingual-e5-small_quantized.onnx" />
    <tokenizer-model path="me5/tokenizer.json" />
    <normalize>true</normalize>
    <pooling-strategy>mean</pooling-strategy>
</component>

<component id="me5_small" type="hugging-face-embedder">
    <transformer-model path="me5/intfloat-multilingual-e5-small.onnx" />
    <tokenizer-model path="me5/tokenizer.json" />
    <normalize>true</normalize>
    <pooling-strategy>mean</pooling-strategy>
</component>

or url

        <component id="me5_small_fp16" type="hugging-face-embedder">
            <transformer-model
                url="https://huggingface.co/hotchpotch/vespa-onnx-intfloat-multilingual-e5-small/resolve/main/intfloat-multilingual-e5-small_fp16.onnx" />
            <tokenizer-model
                url="https://huggingface.co/hotchpotch/vespa-onnx-intfloat-multilingual-e5-small/resolve/main/tokenizer.json" />
            <normalize>true</normalize>
            <pooling-strategy>mean</pooling-strategy>
        </component>
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
from torch import Tensor
import torch
import torch.nn.functional as F

model_name = "hotchpotch/vespa-onnx-intfloat-multilingual-e5-small"
onnx_file_name = "intfloat-multilingual-e5-small.onnx"

model = ORTModelForSequenceClassification.from_pretrained(
    model_name, file_name=onnx_file_name
)
# override for last_hidden_states
model.output_names["logits"] = 0
tokenizer = AutoTokenizer.from_pretrained(model_name)


def average_pool(last_hidden_state: Tensor, attention_mask: Tensor) -> Tensor:
    last_hidden = last_hidden_state.masked_fill(~attention_mask[..., None].bool(), 0.0)
    return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]


input_texts = [
    "query: What is the capital of Japan?",
    "query: 日本の首都は?",  # "What is the capital of Japan?" in Japanese
    "passage: ニューヨークは大きな都市です年エネ年エネ",  # "New York is a big city" in Japanese
    "passage: 東京は良い場所です",  # "Tokyo is a good place" in Japanese, Tokyo is the capital of Japan.
]

batch_dict = tokenizer(
    input_texts, max_length=512, padding=True, truncation=True, return_tensors="pt"
)

if "token_type_ids" not in batch_dict:
    batch_dict["token_type_ids"] = torch.zeros_like(batch_dict["input_ids"])

# logits is last_hidden_state
last_hidden_states = model(**batch_dict).logits
embeddings = average_pool(last_hidden_states, batch_dict["attention_mask"])

# same vespa embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)

# similarity score
print(embeddings[:2] @ embeddings[2:].T)
License

same e5 (MIT)

Attribution

All credits for this model go to the authors of Multilingual-E5-large and the associated researchers and organizations. When using this model, please be sure to attribute the original authors.

Runs of hotchpotch vespa-onnx-intfloat-multilingual-e5-small on huggingface.co

12
Total runs
0
24-hour runs
0
3-day runs
1
7-day runs
5
30-day runs

More Information About vespa-onnx-intfloat-multilingual-e5-small huggingface.co Model

More vespa-onnx-intfloat-multilingual-e5-small license Visit here:

https://choosealicense.com/licenses/mit

vespa-onnx-intfloat-multilingual-e5-small huggingface.co

vespa-onnx-intfloat-multilingual-e5-small huggingface.co is an AI model on huggingface.co that provides vespa-onnx-intfloat-multilingual-e5-small's model effect (), which can be used instantly with this hotchpotch vespa-onnx-intfloat-multilingual-e5-small model. huggingface.co supports a free trial of the vespa-onnx-intfloat-multilingual-e5-small model, and also provides paid use of the vespa-onnx-intfloat-multilingual-e5-small. Support call vespa-onnx-intfloat-multilingual-e5-small model through api, including Node.js, Python, http.

vespa-onnx-intfloat-multilingual-e5-small huggingface.co Url

https://huggingface.co/hotchpotch/vespa-onnx-intfloat-multilingual-e5-small

hotchpotch vespa-onnx-intfloat-multilingual-e5-small online free

vespa-onnx-intfloat-multilingual-e5-small huggingface.co is an online trial and call api platform, which integrates vespa-onnx-intfloat-multilingual-e5-small's modeling effects, including api services, and provides a free online trial of vespa-onnx-intfloat-multilingual-e5-small, you can try vespa-onnx-intfloat-multilingual-e5-small online for free by clicking the link below.

hotchpotch vespa-onnx-intfloat-multilingual-e5-small online free url in huggingface.co:

https://huggingface.co/hotchpotch/vespa-onnx-intfloat-multilingual-e5-small

vespa-onnx-intfloat-multilingual-e5-small install

vespa-onnx-intfloat-multilingual-e5-small is an open source model from GitHub that offers a free installation service, and any user can find vespa-onnx-intfloat-multilingual-e5-small on GitHub to install. At the same time, huggingface.co provides the effect of vespa-onnx-intfloat-multilingual-e5-small install, users can directly use vespa-onnx-intfloat-multilingual-e5-small installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

vespa-onnx-intfloat-multilingual-e5-small install url in huggingface.co:

https://huggingface.co/hotchpotch/vespa-onnx-intfloat-multilingual-e5-small

Url of vespa-onnx-intfloat-multilingual-e5-small

vespa-onnx-intfloat-multilingual-e5-small huggingface.co Url

Provider of vespa-onnx-intfloat-multilingual-e5-small huggingface.co

hotchpotch
ORGANIZATIONS

Other API from hotchpotch