-
Notifications
You must be signed in to change notification settings - Fork 483
feat(model): validate model name configuration #1084
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
Conversation
Unsolicited suggestion: WDYT about warning with a deprecation message if the model is specified in the parameters field? If we could gradually direct folks to use the dedicated model field, that might be simpler in the long run. Sometimes, the straightjacket is the right fit. My $0.02. |
It is still ok to set But I agree, If someone is using something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, and the tests cover all the permutations of config in main model / parameters with model
and model_name
. I have a couple of questions though:
- Why do we need to support models in both the yaml config and parameters?
- Why not standardize on just
model
rather than bothmodel
andmodel_name
?
in the
it depends on the langchain model and provider used, and in llmrails.py we are checking this explicitly: if model_config.model:
# Some LLM providers use `model_name` instead of `model`.
# Use the `__fields__` attribute which is computed dynamically by pydantic.
if "model" in provider_cls.__fields__:
kwargs["model"] = model_config.model
if "model_name" in provider_cls.__fields__:
kwargs["model_name"] = model_config.model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is useful, kudos for the tests.
@mikemckiernan , maybe we should make more explicit that we accept both model
and model_name
in parameters, depending on how langchain providers are naming this key / attribute?
Isn't it that what we really want to emphasize is that the top-level |
The if model_config.model:
# Some LLM providers use `model_name` instead of `model`.
# Use the `__fields__` attribute which is computed dynamically by pydantic.
if "model" in provider_cls.__fields__:
kwargs["model"] = model_config.model
if "model_name" in provider_cls.__fields__:
kwargs["model_name"] = model_config.model so at the end Please let me know if there are further objections that must be addressed in this PR. I'd like to merge it tomorrow as it is blocking two other PRs. We can follow up on it in separate PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my feedback is never blocking. I appreciate the heads up and the chance to peek at the change. TY!
My comment here was that here the
We can merge this, but maybe we should highlight in the docs in another MR that the https://docs.nvidia.com/nemo/guardrails/latest/user-guides/configuration-guide.html |
Implement proper model name validation in the Model class to ensure that a model name is specified exactly once, either directly via the 'model' field or through parameters. This also normalizes the configuration by moving model names from parameters to the dedicated model field. Add tests to verify all validation scenarios fix: ensure custom_model config has model
25a353b
to
457c532
Compare
Description
Implement proper model name validation in the Model class to ensure that a model name is specified exactly once, either directly via the 'model' field or through parameters. This also normalizes the configuration by moving model names from parameters to the dedicated model field.
Add tests to verify all validation scenarios
Add log.info to warn the user about this change per Mike's suggestion OR do not pop it from Model