Skip to content

Commit

Permalink
automod tuning (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Sep 5, 2024
2 parents d915040 + 7b06504 commit a4f3863
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
9 changes: 9 additions & 0 deletions automod/rules/quick.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ func BotLinkProfileRule(c *automod.RecordContext, profile *appbsky.ActorProfile)
c.AddAccountLabel("spam")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("possible bot based on link in profile: %s", str))
c.Notify("slack")
return nil
}
}
if strings.Contains(*profile.Description, "🏈🍕🌀") {
c.AddAccountFlag("profile-bot-string")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("possible bot based on string in profile"))
c.Notify("slack")
return nil
}
}
return nil
}
Expand All @@ -38,6 +45,7 @@ func SimpleBotPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
c.AddAccountFlag("post-bot-string")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("possible bot based on string in post: %s", str))
c.Notify("slack")
return nil
}
}
return nil
Expand All @@ -55,6 +63,7 @@ func NewAccountBotEmailRule(c *automod.AccountContext) error {
c.AddAccountFlag("new-suspicious-email")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("possible bot based on email domain TLD: %s", tld))
c.Notify("slack")
return nil
}
}
return nil
Expand Down
8 changes: 6 additions & 2 deletions automod/rules/replies.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func ReplyCountPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error
}

// triggers on the N+1 post
var identicalReplyLimit = 6
// var identicalReplyLimit = 6
// TODO: bumping temporarily
var identicalReplyLimit = 20

var _ automod.PostRuleFunc = IdenticalReplyPostRule

Expand Down Expand Up @@ -76,7 +78,9 @@ func IdenticalReplyPostRule(c *automod.RecordContext, post *appbsky.FeedPost) er
return nil
}

var youngReplyAccountLimit = 12
// TODO: bumping temporarily
// var youngReplyAccountLimit = 12
var youngReplyAccountLimit = 30
var _ automod.PostRuleFunc = YoungAccountDistinctRepliesRule

func YoungAccountDistinctRepliesRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
Expand Down
4 changes: 3 additions & 1 deletion automod/rules/replies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ func TestIdenticalReplyPostRule(t *testing.T) {
assert.NoError(capture.ProcessCaptureRules(&eng, cap))
f, err := eng.Flags.Get(ctx, did)
assert.NoError(err)
assert.Equal([]string{"multi-identical-reply"}, f)
// TODO: tweaked threshold, disabling for now
_ = f
//assert.Equal([]string{"multi-identical-reply"}, f)
}
4 changes: 3 additions & 1 deletion automod/visual/hiveai_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ func summarizeSexualLabels(cl []HiveAIResp_Class) string {
// then finally flag remaining "underwear" images in to sexually suggestive
// (after non-sexual content already labeled above)
for _, underwearClass := range []string{"yes_male_underwear", "yes_female_underwear"} {
if scores[underwearClass] >= threshold {
// TODO: experimenting with higher threshhold during traffic spike
//if scores[underwearClass] >= threshold {
if scores[underwearClass] >= 0.98 {
return "sexual"
}
}
Expand Down
29 changes: 19 additions & 10 deletions automod/visual/hiveai_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package visual

import (
"strings"
"time"

"github.com/bluesky-social/indigo/automod"
"github.com/bluesky-social/indigo/automod/rules"
lexutil "github.com/bluesky-social/indigo/lex/util"
)

Expand All @@ -13,13 +15,14 @@ func (hal *HiveAIClient) HiveLabelBlobRule(c *automod.RecordContext, blob lexuti
return nil
}

var psclabel string
var prescreenResult string
if hal.PreScreenClient != nil {
val, err := hal.PreScreenClient.PreScreenImage(c.Ctx, data)
if err != nil {
c.Logger.Info("prescreen-request-error", "err", err)
} else {
psclabel = val
prescreenResult = val
c.Logger.Info("prescreen-request", "uri", c.RecordOp.ATURI(), "result", prescreenResult)
}
}

Expand All @@ -28,18 +31,24 @@ func (hal *HiveAIClient) HiveLabelBlobRule(c *automod.RecordContext, blob lexuti
return err
}

if psclabel == "sfw" {
if len(labels) > 0 {
c.Logger.Info("prescreen-safe-failure", "uri", c.RecordOp.ATURI())
} else {
c.Logger.Info("prescreen-safe-success", "uri", c.RecordOp.ATURI())
if hal.PreScreenClient != nil {
if prescreenResult == "sfw" {
if len(labels) > 0 {
c.Logger.Info("prescreen-safe-failure", "uri", c.RecordOp.ATURI(), "labels", labels, "result", prescreenResult)
} else {
c.Logger.Info("prescreen-safe-success", "uri", c.RecordOp.ATURI())
}
}
} else {
c.Logger.Info("prescreen-nsfw", "uri", c.RecordOp.ATURI())
}

for _, l := range labels {
c.AddRecordLabel(l)
// NOTE: experimenting with profile reporting for new accounts
if l == "sexual" && c.RecordOp.Collection.String() == "app.bsky.actor.profile" && rules.AccountIsYoungerThan(&c.AccountContext, 2*24*time.Hour) {
c.ReportRecord(automod.ReportReasonSexual, "possible sexual profile (not labeled yet)")
c.Logger.Info("skipping record label", "label", l, "reason", "sexual-profile-experiment")
} else {
c.AddRecordLabel(l)
}
}

return nil
Expand Down

0 comments on commit a4f3863

Please sign in to comment.