OMEGA
OMEGA
Bases: RandomFewShot
OMEGA: OptiMizEr as Genetic Algorithm - A genetic optimizer with dominated novelty search.
For now, only 2 based modules features self-evolving trainable variables:
- The
Generator
module (and all modules using it) that has self-evolving instructions. - The
PythonSynthesis
module that has self-evolving python scripts.
More will be added in a near future.
Dominated Novelty Search, is a SOTA Quality-Diversity optimization method that implements a competition function.
The key insight behind Dominated Novelty Search is that candidates should be eliminated from the population if they are both:
- Inferior in reward/fitness
- Similar to existing candidates/solutions
In our case, an embedding model is used to compute a descriptor in order to measure the similarity of candidates.
This allow the system to explore the search space more quickly by eliminating non-promising candidates while preserving diversity to avoid local minima.
This algorithm creates an evolutionary pressure to focus on high performing candidates Or candidates that explore other approaches.
This approach only add one step to the traditional genetic algorithm and outperform MAP-Elites, Threshold-Elites and Cluster-Elites.
Concerning the inspirations for this optimizer
- Dominated Novelty Search for the solution to the problem of diversity in genetic algorithms.
- DSPY's GEPA for feeding the optimizer program with the raw training data and for formalizing the evolutionary optimization strategy (not the MAP-Elites method used).
- AlphaEvolve have been a huge inspiration, more on the motivational side as they didn't released the code.
References
Parameters:
Name | Type | Description | Default |
---|---|---|---|
language_model
|
LanguageModel
|
The language model to use. |
None
|
embedding_model
|
EmbeddingModel
|
The embedding model to use to compute candidates descriptors according to Dominated Novelty Search. |
None
|
k_nearest_fitter
|
int
|
The K nearest fitter used by Dominated Novelty Search. |
5
|
distance_function
|
callable
|
Optional. The distance function to use by Dominated Novelty Search. If no function is provided, use the default cosine distance. |
None
|
mutation_temperature
|
float
|
The temperature for the LM calls of the mutation programs. |
1.0
|
crossover_temperature
|
float
|
The temperature for the LM calls of the crossover programs. |
1.0
|
few_shot_learning
|
bool
|
If |
False
|
nb_min_examples
|
int
|
The min number of examples for few-shot learning (Default to 1). |
1
|
nb_max_examples
|
int
|
The max number of examples for few-shot learning (Default to 3). |
3
|
sampling_temperature
|
float
|
The temperature for softmax sampling of the few-shot learning examples. Lower values concentrate sampling on high-reward predictions, higher values make sampling more uniform (Default 1.0). |
1.0
|
merging_rate
|
float
|
Rate at which crossover vs mutation is selected. (Default to 0.02). |
0.02
|
population_size
|
int
|
The maximum number of best candidates to keep during the optimization process. |
10
|
name
|
str
|
Optional name for the optimizer instance. |
None
|
description
|
str
|
Optional description of the optimizer instance. |
None
|
Source code in synalinks/src/optimizers/omega.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
build(trainable_variables)
async
Build the optimizer programs based on the trainable variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trainable_variables
|
list
|
List of variables that will be optimized |
required |
Source code in synalinks/src/optimizers/omega.py
competition(candidates)
async
This function implement Dominated Novelty Search paper.
This implement the competition function allowing to eliminate non-promising solutions to focus on fittest or non-similar ones.
Source code in synalinks/src/optimizers/omega.py
on_epoch_end(epoch, trainable_variables)
async
Called at the end of an epoch
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch
|
int
|
The epoch number |
required |
trainable_variables
|
list
|
The list of trainable variables |
required |
Source code in synalinks/src/optimizers/omega.py
base_instructions()
Base instructions that define the context for all optimization programs. These instructions explain that the system optimizes JSON variables in a computation graph.
Source code in synalinks/src/optimizers/omega.py
crossover_instructions(variables_keys)
Instructions for the crossover program that optimizes variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variables_keys
|
list
|
List of keys that the variable should contain |
required |
Source code in synalinks/src/optimizers/omega.py
mutation_instructions(variables_keys)
Instructions for the mutation program that optimizes variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variables_keys
|
list
|
List of keys that the variable should contain |
required |
Source code in synalinks/src/optimizers/omega.py
similarity_distance(candidate1, candidate2, embedding_model=None, axis=-1)
async
The default cosine similarity distance used by Dominated Novelty Search
Parameters:
Name | Type | Description | Default |
---|---|---|---|
candidate1
|
dict
|
The first variable candidate |
required |
candidate2
|
dict
|
The second variable candidate |
required |
embedding_model
|
EmbeddingModel
|
The embedding model to use |
None
|
axis
|
int
|
The axis along which compute the similarity (default -1) |
-1
|