CoolFace
Modelpublic

Mohamed-Hanafy-mostafa/bge-small-jobs-finetuned

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes13downloads
Model Card

bge-small-jobs-finetuned

Fine-tuned BAAI/bge-small-en-v1.5 on jobs data, exported and quantized to ONNX INT8 (~4x smaller than FP32).

Usage

python
import onnxruntime as ort
from transformers import AutoTokenizer
import numpy as np

tokenizer = AutoTokenizer.from_pretrained('Mohamed-Hanafy-mostafa/bge-small-jobs-finetuned')
session   = ort.InferenceSession('model_quantized.onnx')

def embed(texts):
    enc  = tokenizer(texts, padding=True, truncation=True, max_length=64, return_tensors='np')
    out  = session.run(['last_hidden_state'],
                       {'input_ids': enc['input_ids'], 'attention_mask': enc['attention_mask']})
    mask = enc['attention_mask'][..., np.newaxis]
    embs = np.sum(out[0] * mask, axis=1) / np.sum(mask, axis=1)
    return embs / np.linalg.norm(embs, axis=1, keepdims=True)

embeddings = embed(['python backend developer', 'ML engineer pytorch'])
print(embeddings.shape)  # (2, 384)