Skip to content

Commit

Permalink
🩹 actually using sigmoid now
Browse files Browse the repository at this point in the history
  • Loading branch information
PsicoThePato committed Apr 30, 2024
1 parent 3b97e31 commit 2f99ad7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/synthia/validator/text_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .generate_data import InputGenerator
from .meta_prompt import get_miner_prompt, Criteria
from .similarity import Embedder, OpenAIEmbedder, OpenAISettings, euclidean_distance
from .math import threshold_sigmoid_reward_distribution
from .sigmoid import threshold_sigmoid_reward_distribution

# TODO: make it match ipv6
IP_REGEX = re.compile(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+")
Expand Down Expand Up @@ -54,7 +54,7 @@ def set_weights(
# Iterate over the items in the score_dict
for uid, score in adjsuted_to_sigmoid.items():
# Calculate the normalized weight as an integer
weight = int(score / scores * 100)
weight = int(score * 1000 / scores)

# Add the weighted score to the new dictionary
weighted_scores[uid] = weight
Expand Down Expand Up @@ -233,6 +233,7 @@ def _get_miner_prediction(
) -> str | None:
connection, miner_key = miner_info
module_ip, module_port = connection

client = ModuleClient(module_ip, int(module_port), self.key)
try:
miner_answer = asyncio.run(
Expand All @@ -247,6 +248,7 @@ def _get_miner_prediction(
log(f"Miner {module_ip}:{module_port} failed to generate an answer")
print(e)
miner_answer = None

return miner_answer

def _get_unit_euclid_distance(
Expand Down Expand Up @@ -355,7 +357,6 @@ async def validate_step(
log(f"similarity: {similarity}")
response_cache.append(miner_answer)

time.sleep(0.5)
# score has to be lower or eq to 1, as one is the best score
assert score <= 1
score_dict[uid] = score
Expand Down Expand Up @@ -421,3 +422,4 @@ def validation_loop(self, settings: ValidatorSettings | None = None) -> None:
sleep_time = settings.iteration_interval - elapsed
log(f"Sleeping for {sleep_time}")
time.sleep(sleep_time)

0 comments on commit 2f99ad7

Please sign in to comment.