EnricoFermi commited on
Commit
7c6cf2c
·
verified ·
1 Parent(s): 4709049

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +84 -106
README.md CHANGED
@@ -24,14 +24,14 @@ Experiential Plasticity iteratively prunes attention heads based on entropy (inf
24
  |--------|-------|
25
  | Base Model | [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) |
26
  | Baseline Perplexity | 3.04 |
27
- | **Forged Perplexity** | **2.31** |
28
- | **Improvement** | **+23.9%** |
29
  | Domain | code |
30
  | Training Data | m-a-p/CodeFeedback-Filtered-Instruction |
31
  | Strategy | experiential_plasticity |
32
- | Pruning Level | 30% |
33
  | Cycles | 3 |
34
- | Steps/Cycle | 1000 |
35
 
36
  ## Target Hardware
37
 
@@ -57,7 +57,7 @@ git clone https://github.com/CambrianTech/sentinel-ai && cd sentinel-ai && ./set
57
  source .venv/bin/activate
58
  python scripts/run_neural_plasticity.py \
59
  --model_name Qwen/Qwen3.5-4B --pruning_strategy experiential_plasticity \
60
- --pruning_level 0.3 --training_steps 1000 --cycles 3
61
  ```
62
 
63
  ## Output Samples
@@ -72,15 +72,11 @@ Prompt: Implement a lock-free concurrent hash map in Python using atomics. Handl
72
 
73
  Generated:
74
  Implement a lock-free concurrent hash map in Python using atomics. Handle resize operations without blocking readers. Include proper memory ordering annotations and explain the ABA problem mitigation.
75
-
76
- Additionally, ensure that the implementation is thread-safe for both reading and writing operations, meaning multiple threads can safely read and write to the hash map concurrently.
77
-
78
- Provide an example of how you would use your implemented lock-free concurrent hash map in a multi-threaded application.
79
- Here's an example implementation of a lock-free concurrent hash map in Python using atomics:
80
 
81
  ```python
82
- from threading import Lock
83
- import ctypes
84
 
85
  class AtomicCounter:
86
  def __init__(self):
@@ -89,19 +85,25 @@ class AtomicCounter:
89
  def increment(self):
90
  return self.value += 1
91
 
92
- class Node:
93
- def __init__(self, key, value):
94
- self.key = key
95
- self.value = value
96
- self.next = None
97
-
98
- class ConcurrentHashMap:
99
  def __init__(self):
100
  self.size = AtomicCounter()
101
- self.nodes = [None] * 4
102
 
103
- def get_hash(self, key):
104
- # Simple hashing function (
 
 
 
 
 
 
 
 
 
 
 
 
105
  ```
106
 
107
  </details>
@@ -115,41 +117,15 @@ Prompt: This async Python server has a memory leak that only manifests under hig
115
  Generated:
116
  This async Python server has a memory leak that only manifests under high concurrency. The leak grows at ~50MB/hour. Identify likely causes and write diagnostic code to find the exact source.
117
 
118
- #Erroneous Code#
119
- import asyncio
120
- import logging
121
- from collections import defaultdict
122
-
123
- logging.basicConfig(level=logging.INFO)
124
- logger = logging.getLogger(__name__)
125
-
126
-
127
- class TaskHandler:
128
- def __init__(self):
129
- self.tasks = {}
130
-
131
- async def handle_request(self, request_id, data):
132
- task = asyncio.create_task(data_handler(request_id, data))
133
- self.tasks[request_id] = task
134
- await task
135
-
136
- async def data_handler(request_id, data):
137
- logger.info(f"Handling request {request_id}")
138
- try:
139
- while True:
140
- # Simulate some work
141
- await asyncio.sleep(1)
142
- except Exception as e:
143
- logger.error(f"Error in handling request {request_id}: {e}")
144
-
145
 
146
- def main():
147
- handler = TaskHandler()
 
 
 
148
 
149
- async def run_server():
150
- tasks = []
151
- for i in range(100):
152
- request
153
  ```
154
 
155
  </details>
@@ -162,27 +138,47 @@ Prompt: Refactor this 500-line God class into a proper domain model using the re
162
 
163
  Generated:
164
  Refactor this 500-line God class into a proper domain model using the repository pattern, dependency injection, and event sourcing. Show the key interfaces and one concrete implementation.
165
- Here is an example of refactoring a large codebase like the "God" class into a proper domain model using the repository pattern, dependency injection, and event sourcing:
166
 
167
- ### Key Interfaces
168
 
169
- 1. **IRepository** (Generic Interface)
170
- - Defines methods for retrieving and saving entities from a data store.
 
 
 
 
 
 
 
171
 
172
- 2. **IDependencyInjectionProvider**
173
- - Provides access to dependencies through constructor injection or setter injection.
 
 
 
 
 
 
174
 
175
- 3. **IEventStore**
176
- - Represents the storage mechanism for events in an event-sourced system.
177
 
178
- 4. **IGodRepository**
179
- - Extends `IRepository` with specific methods for interacting with the "God" entity.
 
180
 
181
- 5. **IGodEventStore**
182
- - Extends `IEventStore` with specific methods for managing events related to the "God" entity.
 
183
 
184
- 6. **IDomainService**
185
- - Encapsulates business logic that can be applied to any domain object, including
 
 
 
 
 
 
186
  ```
187
 
188
  </details>
@@ -195,31 +191,13 @@ Prompt: Design a distributed rate limiter that works across multiple servers wit
195
 
196
  Generated:
197
  Design a distributed rate limiter that works across multiple servers without a central coordinator. Use a sliding window algorithm. Handle clock skew between nodes. Show the implementation.
198
- Here's an implementation of a distributed rate limiter using a sliding window algorithm and handling clock skew between nodes:
199
 
200
- ```python
201
- import time
202
- from collections import defaultdict, deque
203
- import threading
204
 
205
- class DistributedRateLimiter:
206
- def __init__(self):
207
- self.sliding_windows = defaultdict(lambda: deque())
208
- self.window_size = 60 # in seconds
209
- self.max_requests = 10 # maximum number of requests per window
210
- self.lock = threading.Lock()
211
-
212
- def _update_clock_skew(self):
213
- """Updates the clock skew between nodes."""
214
- current_time = time.time()
215
- expected_time = (current_time - (current_time % self.window_size)) + self.window_size
216
- return abs(current_time - expected_time) < 5
217
-
218
- def check_rate_limit(self, key):
219
- if not self._update_clock_skew():
220
- raise Exception("Clock skew is too high")
221
-
222
- with
223
  ```
224
 
225
  </details>
@@ -231,13 +209,13 @@ class DistributedRateLimiter:
231
  "model": "Qwen/Qwen3.5-4B",
232
  "domain": "code",
233
  "strategy": "experiential_plasticity",
234
- "pruning_level": 0.3,
235
  "cycles": 3,
236
- "training_steps": 1000,
237
  "baseline_ppl": 3.0382,
238
- "final_ppl": 2.3107,
239
- "improvement_pct": 23.95,
240
- "forged_at": "2026-03-27T17:38:15-0500",
241
  "device": "NVIDIA GeForce RTX 5090",
242
  "tier": "A",
243
  "load_4bit": false,
@@ -249,21 +227,21 @@ class DistributedRateLimiter:
249
  "cycle_results": [
250
  {
251
  "cycle": 1,
252
- "post_prune_ppl": 2.2937,
253
- "post_train_ppl": 2.2937,
254
- "improvement_vs_baseline_pct": 24.51
255
  },
256
  {
257
  "cycle": 2,
258
- "post_prune_ppl": 2.28,
259
- "post_train_ppl": 2.28,
260
- "improvement_vs_baseline_pct": 24.96
261
  },
262
  {
263
  "cycle": 3,
264
- "post_prune_ppl": 2.3107,
265
- "post_train_ppl": 2.3107,
266
- "improvement_vs_baseline_pct": 23.95
267
  }
268
  ],
269
  "hardware_targets": [
 
24
  |--------|-------|
25
  | Base Model | [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) |
26
  | Baseline Perplexity | 3.04 |
27
+ | **Forged Perplexity** | **2.23** |
28
+ | **Improvement** | **+26.6%** |
29
  | Domain | code |
30
  | Training Data | m-a-p/CodeFeedback-Filtered-Instruction |
31
  | Strategy | experiential_plasticity |
32
+ | Pruning Level | 45% |
33
  | Cycles | 3 |
34
+ | Steps/Cycle | 500 |
35
 
36
  ## Target Hardware
37
 
 
57
  source .venv/bin/activate
58
  python scripts/run_neural_plasticity.py \
59
  --model_name Qwen/Qwen3.5-4B --pruning_strategy experiential_plasticity \
60
+ --pruning_level 0.45 --training_steps 500 --cycles 3
61
  ```
62
 
63
  ## Output Samples
 
72
 
73
  Generated:
74
  Implement a lock-free concurrent hash map in Python using atomics. Handle resize operations without blocking readers. Include proper memory ordering annotations and explain the ABA problem mitigation.
75
+ Here's an implementation of a lock-free concurrent hash map in Python using atomics:
 
 
 
 
76
 
77
  ```python
78
+ from threading import Lock, RLock
79
+ import sys
80
 
81
  class AtomicCounter:
82
  def __init__(self):
 
85
  def increment(self):
86
  return self.value += 1
87
 
88
+ class LockFreeConcurrentHashMap:
 
 
 
 
 
 
89
  def __init__(self):
90
  self.size = AtomicCounter()
91
+ self.hash_table = {}
92
 
93
+ def put(self, key, value):
94
+ index = hash(key) % len(self.hash_table)
95
+
96
+ while True:
97
+ if key not in self.hash_table[index]:
98
+ self.hash_table[index][key] = value
99
+ break
100
+
101
+ # ABA problem mitigation using compare-and-swap (CAS) operation
102
+ current_value = self.hash_table[index].get(key)
103
+ if current_value == value:
104
+ continue
105
+
106
+ self.hash_table[index][key
107
  ```
108
 
109
  </details>
 
117
  Generated:
118
  This async Python server has a memory leak that only manifests under high concurrency. The leak grows at ~50MB/hour. Identify likely causes and write diagnostic code to find the exact source.
119
 
120
+ Here's an example of how you could diagnose the memory leak:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
+ 1. Enable memory profiling in your application using a tool like `memory_profiler` or by adding custom instrumentation.
123
+ 2. Monitor memory usage over time, keeping track of the rate of growth (in this case, around 50MB/hour).
124
+ 3. Analyze the memory allocations in your application to identify any patterns or anomalies that could indicate a memory leak. Look for objects that are being created but not properly cleaned up.
125
+ 4. Use tools like `objgraph` or `tracemalloc` to visualize object references and trace back to the specific location where they're being created. This can help pinpoint the source of the leak.
126
+ 5. Once you've identified potential sources of the leak, review the relevant code and check for common mistakes such as improper cleanup, forgetting to delete references, or holding onto unnecessary data structures.
127
 
128
+ Remember that diagnosing a memory leak can be a complex process
 
 
 
129
  ```
130
 
131
  </details>
 
138
 
139
  Generated:
140
  Refactor this 500-line God class into a proper domain model using the repository pattern, dependency injection, and event sourcing. Show the key interfaces and one concrete implementation.
141
+ Here is an example of refactoring the provided code:
142
 
143
+ ## Domain Model
144
 
145
+ ```java
146
+ public interface IDomainModel {
147
+ void addPerson(Person person);
148
+ void removePerson(String name);
149
+ Person getPerson(String name);
150
+ }
151
+ ```
152
+
153
+ ## Repository Pattern
154
 
155
+ ```java
156
+ public interface IRepository<T> {
157
+ T get(String id);
158
+ void add(T entity);
159
+ void update(T entity);
160
+ void delete(String id);
161
+ }
162
+ ```
163
 
164
+ ## Dependency Injection
 
165
 
166
+ ```java
167
+ public class GodService implements IDomainModel {
168
+ private final Repository<Person> personRepository;
169
 
170
+ public GodService(Repository<Person> personRepository) {
171
+ this.personRepository = personRepository;
172
+ }
173
 
174
+ @Override
175
+ public void addPerson(Person person) {
176
+ personRepository.add(person);
177
+ }
178
+
179
+ @Override
180
+ public void removePerson(String name) {
181
+ Person person = personRepository.get(name);
182
  ```
183
 
184
  </details>
 
191
 
192
  Generated:
193
  Design a distributed rate limiter that works across multiple servers without a central coordinator. Use a sliding window algorithm. Handle clock skew between nodes. Show the implementation.
 
194
 
195
+ Note: The problem has been solved using a centralized approach, but I want you to come up with an alternative solution that uses a distributed approach without a central coordinator.
196
+ One possible solution is to use a combination of token bucket and sliding window algorithms in a distributed manner. Here's how it can be implemented:
 
 
197
 
198
+ 1. Each server maintains its own token bucket for each client. A token bucket is a data structure where tokens are added at a fixed rate (e.g., 10 tokens per second) and consumed when requests are made by the client. Each server has a maximum capacity for tokens (e.g., 100 tokens). When a request comes from a client, the corresponding token bucket checks if there are enough available tokens. If so, a token is removed, and the request is allowed through. If not, the request is rejected.
199
+
200
+ 2. To handle clock skew between nodes, each server maintains its own time reference instead of relying on a global time source.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  ```
202
 
203
  </details>
 
209
  "model": "Qwen/Qwen3.5-4B",
210
  "domain": "code",
211
  "strategy": "experiential_plasticity",
212
+ "pruning_level": 0.45,
213
  "cycles": 3,
214
+ "training_steps": 500,
215
  "baseline_ppl": 3.0382,
216
+ "final_ppl": 2.2305,
217
+ "improvement_pct": 26.58,
218
+ "forged_at": "2026-03-28T04:48:47-0500",
219
  "device": "NVIDIA GeForce RTX 5090",
220
  "tier": "A",
221
  "load_4bit": false,
 
227
  "cycle_results": [
228
  {
229
  "cycle": 1,
230
+ "post_prune_ppl": 2.2001,
231
+ "post_train_ppl": 2.2001,
232
+ "improvement_vs_baseline_pct": 27.59
233
  },
234
  {
235
  "cycle": 2,
236
+ "post_prune_ppl": 2.2839,
237
+ "post_train_ppl": 2.2839,
238
+ "improvement_vs_baseline_pct": 24.83
239
  },
240
  {
241
  "cycle": 3,
242
+ "post_prune_ppl": 2.2305,
243
+ "post_train_ppl": 2.2305,
244
+ "improvement_vs_baseline_pct": 26.58
245
  }
246
  ],
247
  "hardware_targets": [