Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom model #463

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add custom model #463

wants to merge 4 commits into from

Conversation

I8dNLo
Copy link
Contributor

@I8dNLo I8dNLo commented Feb 4, 2025

Add custom models to fastembed.text

@I8dNLo I8dNLo requested a review from joein February 4, 2025 13:10
@I8dNLo I8dNLo changed the title add_custom_model draft Add custom model Feb 4, 2025
Comment on lines +108 to +110
@classmethod
def add_custom_model(cls, model_info: dict[str, Any]):
cls.supported_models.append(model_info)
Copy link
Member

@joein joein Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to redefine this method in the subclasses if they fetch the right cls variable

"description": "...",
"license": "apache-2.0",
"size_in_GB": 1.23,
"sources": { ... } # optional
Copy link
Contributor

@hh-space-invader hh-space-invader Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be mandatory ? We use sources to download model/config.

Suggested change
"sources": { ... } # optional
"sources": {
"hf": "alibaba/blablabla"
}

PooledEmbedding.add_custom_model(model_info)
elif mean_pooling and normalization:
PooledNormalizedEmbedding.add_custom_model(model_info)
elif "clip" in model_info["model"].lower():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not always the case. jinaai/jina-clip-v1 model is added to text models (not clip) as it needs normalization.

Suggested change
elif "clip" in model_info["model"].lower():
elif "clip" in model_info["model"].lower() and not normalization:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants