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

Add generation params to inference engines #600

Merged
merged 17 commits into from
Oct 8, 2024

Conversation

oelachqar
Copy link
Contributor

Add Generation Parameters to Inference Engines

This PR introduces a set of missing generation parameters, and updates all the current inference engines to support them, or if not supported by the engine, logs a warning that the parameter will be ignored.

The following parameters are added: temperature, top_p, frequency_penalty, presence_penalty, stop sequences, logit_bias, and min_p.

Towards OPE-328

Changes

  • Updated GenerationParams class with new parameters
  • Implemented parameter support in AnthropicInferenceEngine, LlamaCppInferenceEngine, NativeTextInferenceEngine, RemoteInferenceEngine, and VLLMInferenceEngine

Usage

Setting Generation Parameters

from oumi.core.configs.params.generation_params import GenerationParams

params = GenerationParams(
    max_new_tokens=100,
    temperature=0.7,
    top_p=0.9,
    frequency_penalty=0.1,
    presence_penalty=0.1,
    stop=["END"],
    logit_bias={50256: -100},  # Decrease likelihood of EOS token
    min_p=0.05
)

Using Parameters with an Inference Engine

from oumi.inference.llama_cpp_inference_engine import LlamaCppInferenceEngine

engine = LlamaCppInferenceEngine(model_params, generation_params=params)
response = engine.generate(conversation)

Copy link

linear bot commented Oct 7, 2024

OPE-328

Copy link
Collaborator

@taenin taenin left a comment

Choose a reason for hiding this comment

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

If you want to simplify the warning logic, we could implement a get_supported_params method in the baseInferenceEngine that by default returns an empty set. This method is called by infer() and will print warnings where relevant. Each derivative class could simply implement that method and get alerting as needed. Food for thought though, not completely necessary as we only have a few engines.

Additionally, we should update our unit tests to verify that the new parameters are passed appropriately

@oelachqar
Copy link
Contributor Author

If you want to simplify the warning logic, we could implement a get_supported_params method in the baseInferenceEngine that by default returns an empty set. This method is called by infer() and will print warnings where relevant. Each derivative class could simply implement that method and get alerting as needed. Food for thought though, not completely necessary as we only have a few engines.

Additionally, we should update our unit tests to verify that the new parameters are passed appropriately

That's a great suggestion -- logged OPE-546 to address as a follow-up. Update this PR to include unit tests for the generation params

@oelachqar oelachqar merged commit 5f3780e into main Oct 8, 2024
1 check passed
@oelachqar oelachqar deleted the oelachqar/add_generation_params branch October 8, 2024 16:52
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