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

[ENH]: Add superfast wordllama embedding function #2925

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

Conversation

last-partizan
Copy link

Description of changes

Added new superfast WordLlama embedding function.

I was playing with SeaGOAT, trying to make it better understand code, and make it faster. It uses chromadb, and embedding function is what defines it's speed and usefulness.

So, i tried adding this one.

Embedding time benchmark

(source https://github.com/dleemiller/WordLlama?tab=readme-ov-file#how-fast-zap )

Test plan

  • Tests pass locally with pytest

Documentation Changes

I haven't changed any docs, let me know if we need to add it somewhere.

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor

@tazarov tazarov left a comment

Choose a reason for hiding this comment

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

There are a few minor things; otherwise, it looks good. Thanks.

chromadb/test/ef/test_wordllama_ef.py Show resolved Hide resolved

def __init__(
self,
config: Literal["l2_supercat", "l3_supercat"] = "l2_supercat",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we stick to standard naming conventions and use model_name instead?

Copy link
Author

Choose a reason for hiding this comment

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

It's not really a model name, it's a config name which is shorthand for model+some parameters.

And it can be used to load configurations from TOML files, so it's better this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Thanks for clarifying. Can you add this to the param description. Or provide a link in the description to point users where to find more info about it.

We lean heavy on DX so that's why the param name struck with me that for some users might cause a confusion unless explained how it works and where to find info.

Copy link
Author

Choose a reason for hiding this comment

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

That's a tricky one.

Source code for reference: https://github.com/dleemiller/WordLlama/blob/main/wordllama/wordllama.py

WordLlama stores several predefined configs, but publicly mentions only those two, and i'm not sure if describing what it is here is a good idea.
And it also accepts WordLlamaConfig, but really with no docs or examples.

From what I see, other configs are used primarily for training, to produce these two fast and small models.

Maybe it's better to leave them just as "configs" with current description, because most intended use-cases use only these parameters anyway.

And, to be precise, load(config: ... accepts str | WordLlamaConfig, so we have a choice between describing it here as Literal with two expected choices, or as str and trying to explain the details user probably does not need (and i may be wrong, because I used only these two choices).

Maybe we should leave this description as it is. I only replaced word 'model' with 'config', to be consistent.

Copy link
Author

Choose a reason for hiding this comment

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

If you have online docs, link them in the file header.

Added description from the repository to class docstring, and also added a link.

(Added as docstring, and not a file header, because other files mostly using docstrings)

Copy link
Contributor

@tazarov tazarov left a comment

Choose a reason for hiding this comment

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

@last-partizan, looks good. Just add some additional info on what the config parameter is and where to find more info. If you have online docs, link them in the file header. It is always useful to have some pointers about this.

One more point, can you look into updating the docs as well?


def __init__(
self,
config: Literal["l2_supercat", "l3_supercat"] = "l2_supercat",
Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Thanks for clarifying. Can you add this to the param description. Or provide a link in the description to point users where to find more info about it.

We lean heavy on DX so that's why the param name struck with me that for some users might cause a confusion unless explained how it works and where to find info.

@tazarov tazarov changed the title feat: Add superfast wordllama embedding function [ENH]: Add superfast wordllama embedding function Oct 10, 2024
@tazarov tazarov added the EF Embedding Functions label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EF Embedding Functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants