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.
Files changed (46) hide show
  1. ai_nk_cce-0.1.0.dist-info/METADATA +118 -0
  2. ai_nk_cce-0.1.0.dist-info/RECORD +46 -0
  3. ai_nk_cce-0.1.0.dist-info/WHEEL +4 -0
  4. api/__init__.py +0 -0
  5. api/mpcdf_vllm.py +94 -0
  6. evals/nk_model.py +277 -0
  7. model/README.md +64 -0
  8. model/config/dataset_conv_v1.yml +9 -0
  9. model/config/dataset_conv_v2_m2.yml +9 -0
  10. model/config/dataset_conv_v3_m2_assembl_nearest.yml +9 -0
  11. model/config/dataset_debug.yml +9 -0
  12. model/config/dataset_v4_int_format.yml +9 -0
  13. model/config/dataset_v5.yml +9 -0
  14. model/config/inference.yml +7 -0
  15. model/config/train.yml +24 -0
  16. model/config/train_debug.yml +19 -0
  17. model/config/train_from_checkpoint.yml +24 -0
  18. model/config/train_from_checkpoint_debug.yml +19 -0
  19. model/config/train_grpo.yml +30 -0
  20. model/config/train_grpo_debug.yml +30 -0
  21. model/config/train_grpo_debug_vllm.yml +32 -0
  22. model/config.py +54 -0
  23. model/dataset.py +324 -0
  24. model/inference.py +51 -0
  25. model/nk_assistant.py +207 -0
  26. model/parser.py +70 -0
  27. model/run_slurm.py +335 -0
  28. model/score.ipynb +596 -0
  29. model/scripts/template.slurm +54 -0
  30. model/scripts/template_rl.slurm +54 -0
  31. model/train.py +293 -0
  32. nk_model/__init__.py +0 -0
  33. nk_model/assembler.py +112 -0
  34. nk_model/biased_prediction_agent.py +389 -0
  35. nk_model/dataset.py +434 -0
  36. nk_model/enums.py +21 -0
  37. nk_model/landscape_cache.py +149 -0
  38. nk_model/models.py +172 -0
  39. nk_model/nk_landscape.py +498 -0
  40. simulation/hill_climber_simulation.py +211 -0
  41. simulation/hill_climber_vs_ai_simulation.py +132 -0
  42. simulation/landscape_selection.py +179 -0
  43. utils/__init__.py +0 -0
  44. utils/binary_conversion.py +128 -0
  45. utils/logging.py +33 -0
  46. 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)