Skip to content

Commit 21c190f

Browse files
committed
feat: Update docs & adding reason to comparer
1 parent 815e59d commit 21c190f

7 files changed

Lines changed: 35 additions & 75 deletions

File tree

docs/1.validator.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ To set up a validator node on the RedTeam Subnet, follow these steps:
147147

148148
You will be prompted to enter your Hugging Face access token. Visit [Hugging Face Access Tokens](https://huggingface.co/settings/tokens) to generate one if you don't have it already.
149149
150-
6. Custom Setup for Specific Challenges
151-
152-
For setup instructions related to specific challenges, please refer to the [Validator Custom Setup](./4.validator_custom.md).
153-
154-
7. Start the validator node:
150+
6. Start the validator node:
155151
156152
```sh
157153
# Activate the virtual environment if not already activated
@@ -173,15 +169,3 @@ To set up a validator node on the RedTeam Subnet, follow these steps:
173169
174170
- `--logging.trace` - Enable trace logging
175171
- `--logging.debug` - Enable debug logging
176-
177-
8. (Optional but Recommended) Start the Auto-Update Script
178-
179-
```sh
180-
# Activate the virtual environment if not already activated
181-
source .venv/bin/activate
182-
183-
# Start auto-updater
184-
pm2 start python --name "validator_autoupdate" \
185-
-- -m scripts.validator_auto_update \
186-
-- --process-name "validator_snxxx"
187-
```
File renamed without changes.

docs/4.validator_custom.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

redteam_core/challenge_pool/ab_sniffer_v3/comparer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _compare_within_batch(self, miner_commit: MinerChallengeCommit):
167167

168168
def _compare_outputs(
169169
self, miner_input: dict, miner_output: dict, reference_output: dict
170-
) -> float:
170+
) -> dict:
171171
"""
172172
Send comparison request to challenge container's /compare endpoint.
173173
@@ -177,7 +177,7 @@ def _compare_outputs(
177177
reference_output: The output from the reference miner
178178
179179
Returns:
180-
float: Comparison score between 0 and 1
180+
dict: Comparison score between 0 and 1, and reason for the score
181181
"""
182182
_protocol, _ssl_verify = self._check_protocol(is_challenger=True)
183183

@@ -198,15 +198,19 @@ def _compare_outputs(
198198
response_data = response.json()
199199
data = response_data.get("data", {})
200200
similarity_score = data.get("similarity_score", 1.0)
201+
similarity_reason = data.get("reason", "Unknown")
201202

202203
# Normalize score to float between 0 and 1
203204
if isinstance(similarity_score, int):
204205
similarity_score = float(similarity_score)
205206
elif not isinstance(similarity_score, float):
206207
similarity_score = 1.0
207208

208-
return max(0.0, min(1.0, similarity_score))
209+
return {
210+
"similarity_score": max(0.0, min(1.0, similarity_score)),
211+
"reason": similarity_reason,
212+
}
209213

210214
except Exception as e:
211215
bt.logging.error(f"Error in comparison request: {str(e)}")
212-
return 0.0
216+
return {"similarity_score": 0.0, "reason": f"Error: {str(e)}"}

redteam_core/challenge_pool/comparer.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _compare_within_batch(self, miner_commit: MinerChallengeCommit):
207207

208208
def _compare_outputs(
209209
self, miner_input: dict, miner_output: dict, reference_output: dict
210-
) -> float:
210+
) -> dict:
211211
"""
212212
Send comparison request to challenge container's /compare endpoint.
213213
@@ -217,7 +217,7 @@ def _compare_outputs(
217217
reference_output: The output from the reference miner
218218
219219
Returns:
220-
float: Comparison score between 0 and 1
220+
dict: Comparison score between 0 and 1, and reason for the score
221221
"""
222222
_protocol, _ssl_verify = self._check_protocol(is_challenger=True)
223223

@@ -235,19 +235,24 @@ def _compare_outputs(
235235
json=payload,
236236
)
237237

238-
similarity_score = response.json()
238+
_result = response.json().get("data", {})
239+
similarity_score = _result.get("similarity_score", 0.0)
240+
similarity_reason = _result.get("reason", "Unknown")
239241

240242
# Normalize score to float between 0 and 1
241243
if isinstance(similarity_score, int):
242244
similarity_score = float(similarity_score)
243245
elif not isinstance(similarity_score, float):
244246
similarity_score = 0.0
245247

246-
return max(0.0, min(1.0, similarity_score))
248+
return {
249+
"similarity_score": max(0.0, min(1.0, similarity_score)),
250+
"reason": similarity_reason,
251+
}
247252

248253
except Exception as e:
249254
bt.logging.error(f"Error in comparison request: {str(e)}")
250-
return 0.0
255+
return {"similarity_score": 0.0, "reason": f"Error: {str(e)}"}
251256

252257
def _setup_challenge(self):
253258
"""

redteam_core/challenge_pool/dev_fingerprinter_v1/comparer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _compare_within_batch(self, miner_commit: MinerChallengeCommit):
164164

165165
def _compare_outputs(
166166
self, miner_input: dict, miner_output: dict, reference_output: dict
167-
) -> float:
167+
) -> dict:
168168
"""
169169
Send comparison request to challenge container's /compare endpoint.
170170
@@ -174,7 +174,7 @@ def _compare_outputs(
174174
reference_output: The output from the reference miner
175175
176176
Returns:
177-
float: Comparison score between 0 and 1
177+
dict: Comparison score between 0 and 1, and reason for the score
178178
"""
179179
_protocol, _ssl_verify = self._check_protocol(is_challenger=True)
180180

@@ -195,15 +195,19 @@ def _compare_outputs(
195195
response_data = response.json()
196196
data = response_data.get("data", {})
197197
similarity_score = data.get("similarity_score", 1.0)
198+
similarity_reason = data.get("reason", "Unknown")
198199

199200
# Normalize score to float between 0 and 1
200201
if isinstance(similarity_score, int):
201202
similarity_score = float(similarity_score)
202203
elif not isinstance(similarity_score, float):
203204
similarity_score = 1.0
204205

205-
return max(0.0, min(1.0, similarity_score))
206+
return {
207+
"similarity_score": max(0.0, min(1.0, similarity_score)),
208+
"reason": similarity_reason,
209+
}
206210

207211
except Exception as e:
208212
bt.logging.error(f"Error in comparison request: {str(e)}")
209-
return 0.0
213+
return {"similarity_score": 0.0, "reason": f"Error: {str(e)}"}

redteam_core/challenge_pool/humanize_behaviour_v5/comparer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _compare_within_batch(self, miner_commit: MinerChallengeCommit):
213213

214214
def _compare_outputs(
215215
self, miner_input: dict, miner_output: dict, reference_output: dict
216-
) -> float:
216+
) -> dict:
217217
"""
218218
Send comparison request to challenge container's /compare endpoint.
219219
@@ -223,7 +223,7 @@ def _compare_outputs(
223223
reference_output: The output from the reference miner
224224
225225
Returns:
226-
float: Comparison score between 0 and 1
226+
dict: Comparison score between 0 and 1, and reason for the score
227227
"""
228228
_protocol, _ssl_verify = self._check_protocol(is_challenger=True)
229229

@@ -244,15 +244,19 @@ def _compare_outputs(
244244
response_data = response.json()
245245
data = response_data.get("data", {})
246246
similarity_score = data.get("similarity_score", 1.0)
247+
similarity_reason = data.get("reason", "Unknown")
247248

248249
# Normalize score to float between 0 and 1
249250
if isinstance(similarity_score, int):
250251
similarity_score = float(similarity_score)
251252
elif not isinstance(similarity_score, float):
252253
similarity_score = 1.0
253254

254-
return max(0.0, min(1.0, similarity_score))
255+
return {
256+
"similarity_score": max(0.0, min(1.0, similarity_score)),
257+
"reason": similarity_reason,
258+
}
255259

256260
except Exception as e:
257261
bt.logging.error(f"Error in comparison request: {str(e)}")
258-
return 0.0
262+
return {"similarity_score": 0.0, "reason": f"Error: {str(e)}"}

0 commit comments

Comments
 (0)