File size: 1,267 Bytes
93e630a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
"""
Utilities for modeling
"""
def get_model_params(
model_id: str,
params: dict,
) -> dict:
"""
Set up a dictionary with model parameters named appropriately for Bedrock
Parameters
----------
model_id : str
Model name
params : dict
Inference parameters
Returns
-------
dict
_description_
"""
model_params = {}
# name parameters based on the model id
if model_id.startswith("amazon"):
model_params = {
"maxTokenCount": params["answer_length"],
"stopSequences": params["stop_words"],
"temperature": params["temperature"],
"topP": params["top_p"],
}
elif model_id.startswith("anthropic"):
model_params = {
"max_tokens_to_sample": params["answer_length"],
"stop_sequences": params["stop_words"],
"temperature": params["temperature"],
"top_p": params["top_p"],
}
elif model_id.startswith("ai21"):
model_params = {
"maxTokens": params["answer_length"],
"stopSequences": params["stop_words"],
"temperature": params["temperature"],
"topP": params["top_p"],
}
return model_params
|