ai-nk-cce 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_nk_cce-0.1.0.dist-info/METADATA +118 -0
- ai_nk_cce-0.1.0.dist-info/RECORD +46 -0
- ai_nk_cce-0.1.0.dist-info/WHEEL +4 -0
- api/__init__.py +0 -0
- api/mpcdf_vllm.py +94 -0
- evals/nk_model.py +277 -0
- model/README.md +64 -0
- model/config/dataset_conv_v1.yml +9 -0
- model/config/dataset_conv_v2_m2.yml +9 -0
- model/config/dataset_conv_v3_m2_assembl_nearest.yml +9 -0
- model/config/dataset_debug.yml +9 -0
- model/config/dataset_v4_int_format.yml +9 -0
- model/config/dataset_v5.yml +9 -0
- model/config/inference.yml +7 -0
- model/config/train.yml +24 -0
- model/config/train_debug.yml +19 -0
- model/config/train_from_checkpoint.yml +24 -0
- model/config/train_from_checkpoint_debug.yml +19 -0
- model/config/train_grpo.yml +30 -0
- model/config/train_grpo_debug.yml +30 -0
- model/config/train_grpo_debug_vllm.yml +32 -0
- model/config.py +54 -0
- model/dataset.py +324 -0
- model/inference.py +51 -0
- model/nk_assistant.py +207 -0
- model/parser.py +70 -0
- model/run_slurm.py +335 -0
- model/score.ipynb +596 -0
- model/scripts/template.slurm +54 -0
- model/scripts/template_rl.slurm +54 -0
- model/train.py +293 -0
- nk_model/__init__.py +0 -0
- nk_model/assembler.py +112 -0
- nk_model/biased_prediction_agent.py +389 -0
- nk_model/dataset.py +434 -0
- nk_model/enums.py +21 -0
- nk_model/landscape_cache.py +149 -0
- nk_model/models.py +172 -0
- nk_model/nk_landscape.py +498 -0
- simulation/hill_climber_simulation.py +211 -0
- simulation/hill_climber_vs_ai_simulation.py +132 -0
- simulation/landscape_selection.py +179 -0
- utils/__init__.py +0 -0
- utils/binary_conversion.py +128 -0
- utils/logging.py +33 -0
- utils/utils.py +51 -0
utils/utils.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import Type, TypeVar
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import yaml
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
# Define a generic type variable that must inherit from BaseModel
|
|
8
|
+
T = TypeVar("T", bound=BaseModel)
|
|
9
|
+
|
|
10
|
+
# Precomputed binary array for fast lookups
|
|
11
|
+
BIN_ARRAY = np.unpackbits(np.arange(0, 256, dtype=np.uint8)[:, None], axis=1)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# array_to_str moved to binary_conversion.binary_array_to_str
|
|
15
|
+
# Import from binary_conversion module instead
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def mod_sub_vec(a, b, n):
|
|
19
|
+
"""
|
|
20
|
+
Subtract two vectors in the ring Z_n.
|
|
21
|
+
Args:
|
|
22
|
+
a: First vector
|
|
23
|
+
b: Second vector
|
|
24
|
+
n: Modulus
|
|
25
|
+
Returns:
|
|
26
|
+
np.ndarray: Result of the subtraction
|
|
27
|
+
Examples:
|
|
28
|
+
>>> mod_sub_vec(np.array([1, 2, 3]), np.array([4, 5, 6]), 7)
|
|
29
|
+
array([4, 4, 4])
|
|
30
|
+
>>> mod_sub_vec(np.array([9, 2, 7]), np.array([4, 4, 4]), 10)
|
|
31
|
+
array([5, 8, 3])
|
|
32
|
+
>>> mod_sub_vec(np.array([1, 2, 3]), np.array([0, 1, 6]), 2)
|
|
33
|
+
array([1, 1, 1])
|
|
34
|
+
"""
|
|
35
|
+
return np.mod(np.mod(a, n) - np.mod(b, n), n)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def load_config_from_yaml(filepath: str, model: Type[T]) -> T:
|
|
39
|
+
"""
|
|
40
|
+
Load a YAML configuration file and parse it into a Pydantic model.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
filepath: Path to the YAML configuration file
|
|
44
|
+
model: Pydantic model class to parse the data into
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Instance of the provided model class with data from YAML
|
|
48
|
+
"""
|
|
49
|
+
with open(filepath, "r") as file:
|
|
50
|
+
data = yaml.safe_load(file)
|
|
51
|
+
return model(**data)
|