LLM-kitchen / utils.py
Keeby-smilyai's picture
Create utils.py
f6a808f verified
# utils.py
ARCH_ANALOGIES = {
"cnn": "🍲 CNN is like a sieve — strains local patterns from your data broth, layer by layer.",
"rnn": "⏲️ RNN is your slow-simmer pot — remembers earlier flavors to enrich the final dish.",
"transformer": "🌡️ Transformer is your sous-vide — precise, parallel, deeply flavorful at every layer."
}
def get_auto_hyperparams(arch_type, num_layers):
"""Auto-Seasoning™ — smart defaults based on architecture and depth"""
base_config = {
"cnn": {"lr": 1e-3, "epochs": 3, "batch": 16},
"rnn": {"lr": 5e-4, "epochs": 4, "batch": 8},
"transformer": {"lr": 3e-4, "epochs": 3, "batch": 4}
}
config = base_config.get(arch_type, base_config["transformer"])
# Adjust for layer depth
if num_layers > 8:
config["lr"] *= 0.6
config["epochs"] += 2
config["batch"] = max(2, config["batch"] // 2)
elif num_layers < 4:
config["lr"] *= 1.3
config["batch"] = min(32, config["batch"] * 2)
return {
"learning_rate": round(config["lr"], 6),
"epochs": config["epochs"],
"batch_size": config["batch"]
}