Spaces:
Sleeping
Sleeping
Download adaptive_cache/workloads.py from pragunk/adaptive_cache_env: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/spaces/pragunk/adaptive_cache_env/resolve/main/adaptive_cache/workloads.py
- Command line
-
hf download hf://spaces/pragunk/adaptive_cache_env/adaptive_cache/workloads.py
-
curl -L -o workloads.py https://huggingface.co/spaces/pragunk/adaptive_cache_env/resolve/main/adaptive_cache/workloads.py
771 Bytes
| import numpy as np | |
| def generate_easy_task(length=100, vocab_size=50): | |
| """Zipfian (power-law) distribution. Standard web traffic.""" | |
| np.random.seed(42) | |
| workload = np.random.zipf(1.5, length) | |
| return np.clip(workload, 1, vocab_size).tolist() | |
| def generate_medium_task(length=100, cache_size=10): | |
| """Sequential scan loop. Defeats standard LRU.""" | |
| sequence = list(range(1, cache_size + 3)) | |
| return (sequence * (length // len(sequence) + 1))[:length] | |
| def generate_hard_task(length=100): | |
| """Shifting working sets. Requires rapid adaptation.""" | |
| np.random.seed(42) | |
| first_half = np.random.randint(1, 20, length // 2).tolist() | |
| second_half = np.random.randint(80, 100, length - (length // 2)).tolist() | |
| return first_half + second_half |