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

Refactoring of internal structure #105

Merged
merged 6 commits into from
Feb 2, 2024
Merged

Conversation

generall
Copy link
Member

@generall generall commented Feb 1, 2024

Why?

  • Provides a structure for further expansion: new types of models, new modalities, sparse/colbert, e.t.c.
  • Provide single entry point for all types of text embedding models, which have same interface
  • Remove obscure logic: exclude param of the model list, multiple sources for the same model (how it was supposed to work?), remove the gcp fallback wrapper
  • Decompose utilities, file-management and model inference into dedicated modules, improve code navigation
  • Increased code re-usage

@generall generall requested review from NirantK and Anush008 February 1, 2024 23:33
Copy link
Member

@Anush008 Anush008 left a comment

Choose a reason for hiding this comment

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

Great 👍
The pre-commit found some left-out formatting changes.

@Anush008
Copy link
Member

Anush008 commented Feb 2, 2024

  • multiple sources for the same model (how it was supposed to work?), remove the gcp fallback wrapper

HF sources were tried first. If they failed or were not present, fallback to GCS.

fastembed/text/e5_onnx_embedding.py Show resolved Hide resolved
fastembed/text/text_embedding.py Show resolved Hide resolved
fastembed/text/onnx_models.py Outdated Show resolved Hide resolved
Comment on lines +12 to +10
DefaultEmbedding = TextEmbedding
FlagEmbedding = TextEmbedding
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this retains enough backward compatibility for most users.

Copy link
Member Author

Choose a reason for hiding this comment

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

that was our thought as well

JinaOnnxEmbedding,
]

@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we handle the case of models which we use for both dense and sparse? E.g. BGE-M3

Copy link
Member Author

Choose a reason for hiding this comment

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

we would need to implement both TextEmbedding and SparseEmbedding(tba) classes for those models. I am strictly against changing the function output format depending on the model name

@@ -0,0 +1,133 @@
supported_flag_models = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to have a flat models.json or similar config-like file, instead of 3 different lists.

If we want to separate the models into different classes and files, we should move this completely to those corresponding files — that way the places to update in any new model addition are:

  1. New class in a file
  2. Embedding Registry
  3. Tests

That's it

Copy link
Member Author

Choose a reason for hiding this comment

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

I am ok with moving lists to the corresponding implementation. But having a single list doesn't work. It creates very ugly hacks as with the "exclude" param of the list models method.

@generall
Copy link
Member Author

generall commented Feb 2, 2024

  • multiple sources for the same model (how it was supposed to work?), remove the gcp fallback wrapper

HF sources were tried first. If they failed or were not present, fallback to GCS.

But what about multiple GCS and multiple HF courses with different names?

@generall
Copy link
Member Author

generall commented Feb 2, 2024

The pre-commit found some left-out formatting changes.

how to run those?

I did a manual run, but it would be nice to mention a setup for the hook in dev docs

@NirantK
Copy link
Contributor

NirantK commented Feb 2, 2024

Added 2 new models to main @generall — let's have those here as well, and then we're good to merge this from my end!

@generall generall force-pushed the refactoring-off-everything branch from c67ebb9 to 7883fa3 Compare February 2, 2024 14:32
}
},
{
"model": "xenova/paraphrase-multilingual-mpnet-base-v2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"model": "xenova/paraphrase-multilingual-mpnet-base-v2",
"model": "sentence-transformers/paraphrase-multilingual-mpnet-base-v2",

This is the model name. I missed this in the PR from Anush. Apologies for the confusion.

Comment on lines 18 to 26
{
"model": "xenova/multilingual-e5-large-quantized",
"dim": 1024,
"description": "Multilingual model. Recommended for non-English languages",
"size_in_GB": 2.24,
"sources": {
"hf": "xenova/multilingual-e5-large",
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
"model": "xenova/multilingual-e5-large-quantized",
"dim": 1024,
"description": "Multilingual model. Recommended for non-English languages",
"size_in_GB": 2.24,
"sources": {
"hf": "xenova/multilingual-e5-large",
}
},

We can delete this completely, since the model is covered by Qdrant now.

@generall generall merged commit a3bc73c into main Feb 2, 2024
14 checks passed
@generall generall deleted the refactoring-off-everything branch February 2, 2024 15:48
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