Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop reputation MF (diligence) training earlier #185

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def _train_one_round(
learningRate=0.2,
logRate=15,
device=torch.device("cpu"),
convergence=10**-7,
convergence=10**-5,
stablePeriod=5,
):
# Identify tensors for training and testing
notes, raters, _ = dataset
Expand All @@ -98,11 +99,12 @@ def _train_one_round(
loss += model.get_regularization_loss()
if logRate and epoch % logRate == 0:
print(f"epoch={epoch:03d} | loss={loss.item():7.4f} | time={time.time() - start:.1f}s")
if priorLoss is not None and (priorLoss - loss).abs() < convergence:
if logRate:
print(f"epoch={epoch:03d} | loss={loss.item():7.4f} | time={time.time() - start:.1f}s")
break
priorLoss = loss
if convergence > 0 and epoch % stablePeriod == 0:
if priorLoss is not None and (priorLoss - loss).abs() < convergence:
if logRate:
print(f"epoch={epoch:03d} | loss={loss.item():7.4f} | time={time.time() - start:.1f}s")
break
priorLoss = loss
# Perform backward pass
loss.backward()
# Update parameters
Expand Down Expand Up @@ -154,7 +156,6 @@ def train_model(
learningRate=learningRate,
logRate=logRate,
device=device,
convergence=-1,
)

# train round 1
Expand All @@ -169,7 +170,6 @@ def train_model(
learningRate=learningRate,
logRate=logRate,
device=device,
convergence=-1,
)

# train round 2
Expand Down Expand Up @@ -204,6 +204,5 @@ def train_model(
learningRate=learningRate,
logRate=logRate,
device=device,
convergence=-1,
)
return loss0, loss1, loss2
5 changes: 3 additions & 2 deletions sourcecode/scoring/tag_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def train_tag_model(
helpfulModelNoteParams: pd.DataFrame = None,
helpfulModelRaterParams: pd.DataFrame = None,
useSigmoidCrossEntropy: bool = True,
name: str = "harassment",
):
print(f"-------------------Training for tag {tag}-------------------")
ratingDataForTag, labelColName = prepare_tag_data(ratings, tag)
Expand Down Expand Up @@ -61,8 +62,8 @@ def train_tag_model(
noteInit=helpfulModelNoteParams,
)

noteParams.columns = [col.replace("internal", "harassment") for col in noteParams.columns]
raterParams.columns = [col.replace("internal", "harassment") for col in raterParams.columns]
noteParams.columns = [col.replace("internal", name) for col in noteParams.columns]
raterParams.columns = [col.replace("internal", name) for col in raterParams.columns]
return noteParams, raterParams, globalBias


Expand Down
Loading