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

Alexandre/add base model option #276

Merged
merged 5 commits into from
Aug 14, 2023
Merged

Conversation

alex-matton
Copy link
Contributor

Add a new base_model option for reranker finetuning to decide which base model to finetune from: english or multilingual.
For the other models (which don't have options), make sure that this variable is not filled.

cohere/client.py Outdated

# Figuring out base model
if internal_custom_model_type in ["GENERATIVE", "CLASSIFICATION"]:
assert base_model is None, "base_model has to be None for generative and classification models"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this validation should happen on the backend

Copy link
Contributor Author

@alex-matton alex-matton Aug 9, 2023

Choose a reason for hiding this comment

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

Oh we had a discussion with Inna and Raphael, and we thought that it made more sense to do an internal mapping here like it's done for internal_custom_model_type with internal_custom_model_type = CUSTOM_MODEL_PRODUCT_MAPPING[model_type]

The other solution without the mapping would be to:

  • use base_model: str = "medium" as default argument of the function
  • this would force the user to specify base_model="english" or base_model="multilingual" for reranker.

I don't have a strong preference here. What do you think is the best solution?

Copy link
Collaborator

@mkozakov mkozakov Aug 9, 2023

Choose a reason for hiding this comment

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

  • for non-rerank finetuning, we want to continue supporting None as a value for the base_model. That allows us to change the default value on the backend.

  • for rerank finetuning, the backend should throw an error "base_model cannot be empty for finetune type "rerank". Must be one of "english" or "multilingual"

no need to keep a map of defaults on the client. This allows us to control default values on the backend, so we can change them if needed without needing to ship a a new client and migrating users to it.

Copy link
Contributor Author

@alex-matton alex-matton Aug 9, 2023

Choose a reason for hiding this comment

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

For non-rerank finetuning, the base_model value has always been "medium":

"baseModel": "medium",

-> that's why I'm thinking of setting "medium" as the default value (to ensure no breaking change) if we don't keep a map of defaults on the client

Copy link
Collaborator

@mkozakov mkozakov Aug 9, 2023

Choose a reason for hiding this comment

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

just like for all other apis, we should not be setting any defaults in the client, so lets just remove that "medium" setting from the SDK and make sure that the backend sets the correct value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raphaelcristal tagging you here as this is probably something you own. Do you think it's possible to do what @mkozakov is suggesting above? I.e. remove the "baseModel":"medium" default and instead add defaults to the backend?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes what Michael says is correct. Best to keep all validation on the backend, so we don't have to deal with deprecations in the sdk. Sorry if I didn't explain this properly when we talked.

cohere/client.py Outdated
internal_base_model = "medium"
elif internal_custom_model_type == "RERANK":
internal_base_model = base_model or "english"
assert internal_base_model in [
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

cohere/client.py Outdated
assert base_model is None, "base_model has to be None for generative and classification models"
internal_base_model = "medium"
elif internal_custom_model_type == "RERANK":
internal_base_model = base_model or "english"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the default should be set on the backend

cohere/responses/custom_model.py Show resolved Hide resolved
Copy link
Collaborator

@mkozakov mkozakov left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

@sanderland sanderland merged commit f60bd70 into main Aug 14, 2023
3 checks passed
@sanderland sanderland deleted the alexandre/add_base_model_option branch August 14, 2023 08:06
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.

4 participants