jina-ai / finetuner

:dart: Task-oriented embedding tuning for BERT, CLIP, etc.
https://finetuner.jina.ai
Apache License 2.0
1.47k stars 67 forks source link

feat: support loading models from hf #751

Closed guenthermi closed 1 year ago

guenthermi commented 1 year ago

feat: support loading models from hf

This PR allows one to load models from https://huggingface.co/jinaai:


import finetuner
import numpy as np

model = finetuner.get_model('jinaai/ecommerce-sbert-model')
e1, e2 = finetuner.encode(model, ['XBox', 'Xbox One Console 500GB - Black (2015)'])

print(f'Similarity: {np.dot(e1,e2)/(np.linalg.norm(e1)*np.linalg.norm(e2))}')
Similarity: 0.7842968702316284