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

Consider normalizing equivalent inference parameters #96

Open
viictorjimenezzz opened this issue Nov 28, 2024 · 2 comments
Open

Consider normalizing equivalent inference parameters #96

viictorjimenezzz opened this issue Nov 28, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@viictorjimenezzz
Copy link

viictorjimenezzz commented Nov 28, 2024

I would find it very helpful if common inference parameters, such as temperature or max. tokens, had normalized argument names. These could then be automatically mapped to the required configuration names for each provider.

For example:

  • AWS provider uses topP and maxTokens
  • OpenAI provider uses top_p and max_tokens

This discrepancy necessitates the use of if-else statements to handle different providers, which seems counter to the framework's goal of streamlining integration.

While I am not a professional developer, here’s an idea for implementation:

# aisuite/providers/__init__.py
NORM_KWARGS_AWS = {
    "max_tokens": "maxTokens",
    "temperature": "temperature",
    "top_p": "topP",
    "stop_sequences": "stopSequences",
}
# aisuite/providers/aws_provider.py
from aisuite.providers import NORM_KWARGS_AWS

for norm_key, value in kwargs.items():
    key = NORM_KWARGS_AWS.get(norm_key, norm_key)
    ...

See: https://github.com/viictorjimenezzz/aisuite

Thank you for considering this request!

@ksolo ksolo added the enhancement New feature or request label Nov 30, 2024
@HOTSONHONET
Copy link

HOTSONHONET commented Dec 1, 2024

I think some kind of translator module if we create, will help in this aspect. The translator module will have the state or the fields of the config.

  • One good thing would have been if we could track the config classes of each Provider 😅. Then hard coding normalized fields won't be required. But yeah, I don't think we can use it here as these providers are being used as packages, And we have no control over the Python environment paths (As they will be user-specific)

Then whenever we call the Provider class and with the set of configs, the translator module will parse the user-given configs to the proper field name w.r.t. the Provider class. Also, for field data type validation can be easily performed by Pydantic.

@HOTSONHONET
Copy link

image

This is my initial approach. ConfigTranslator will use the providers_config.yml which will contain the mapping between different Providers' config and the NORM_KWARGS @viictorjimenezzz mentioned before. And as we keep adding more Providers we can update the YAML file.

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

No branches or pull requests

3 participants