Documentation
¶
Overview ¶
Package moderationml provides ML-powered moderation capabilities using AWS Bedrock.
Index ¶
- Constants
- type Config
- type SampleInput
- type ScoreContentInput
- type ScoreResult
- type Service
- func (s *Service) GetEffectiveness(ctx context.Context, patternID string, period string) (*models.ModerationEffectivenessMetric, error)
- func (s *Service) QueueSamples(ctx context.Context, samples []SampleInput) ([]string, error)
- func (s *Service) ScoreContent(ctx context.Context, input ScoreContentInput) (*ScoreResult, error)
- func (s *Service) SetDB(db core.DB)
- func (s *Service) SetStatusRepository(repo statusRepository)
- func (s *Service) TrainModel(ctx context.Context, tenantID, initiatedBy string, sampleIDs []string, ...) (*TrainingResult, error)
- type TrainingOptions
- type TrainingResult
Constants ¶
const ( EventTypeModelTrainingSubmitted = "MODEL_TRAINING_SUBMITTED" EventTypeModelTrainingCompleted = "MODEL_TRAINING_COMPLETED" EventTypeModelTrainingFailed = "MODEL_TRAINING_FAILED" )
Event types for ML training lifecycle
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
TrainingBucket string
TrainingRegion string
InferenceModelID string
GuardrailID string
GuardrailVersion string
CustomizationRoleARN string
}
Config holds configuration for the ML moderation service
type SampleInput ¶
type SampleInput struct {
ObjectID string
ObjectType string
Label string
ReviewerID string
Confidence float64
Metadata map[string]interface{}
}
SampleInput represents input for creating a training sample
type ScoreContentInput ¶
type ScoreContentInput struct {
Content string
ContentType string
ObjectID string // For prediction tracking
ObjectType string // For prediction tracking
UseGuardrail bool
}
ScoreContentInput represents content to be scored
type ScoreResult ¶
type ScoreResult struct {
Score float64
Labels map[string]float64
GuardrailBlocked bool
GuardrailReason string
ModelVersion string
}
ScoreResult represents the ML moderation score
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides ML moderation operations
func NewService ¶
func NewService( repo moderationMLRepository, awsCfg aws.Config, config Config, logger *zap.Logger, ) *Service
NewService creates a new moderation ML service
func (*Service) GetEffectiveness ¶
func (s *Service) GetEffectiveness(ctx context.Context, patternID string, period string) (*models.ModerationEffectivenessMetric, error)
GetEffectiveness retrieves effectiveness metrics for a pattern/model
func (*Service) QueueSamples ¶
QueueSamples adds training samples to the dataset and returns their IDs
func (*Service) ScoreContent ¶
func (s *Service) ScoreContent(ctx context.Context, input ScoreContentInput) (*ScoreResult, error)
ScoreContent scores content using the active ML model
func (*Service) SetStatusRepository ¶
func (s *Service) SetStatusRepository(repo statusRepository)
SetStatusRepository sets the status repository for content fetching
func (*Service) TrainModel ¶
func (s *Service) TrainModel(ctx context.Context, tenantID, initiatedBy string, sampleIDs []string, options TrainingOptions) (*TrainingResult, error)
TrainModel launches a Bedrock model customization job asynchronously Returns immediately with SUBMITTED status; completion handled via event bus
type TrainingOptions ¶
type TrainingOptions struct {
BaseModelID string
DatasetS3Path string
OutputS3Path string
HyperParameters map[string]string
MaxTrainingTime int
EarlyStoppingEnabled bool
}
TrainingOptions holds options for model training
type TrainingResult ¶
type TrainingResult struct {
Success bool
Status string // SUBMITTED, IN_PROGRESS, COMPLETED, FAILED
JobID string // Bedrock job ARN
JobName string // Human-readable job name
DatasetS3Key string // S3 key of training dataset
ModelVersion string // Model version (empty when SUBMITTED)
ModelARN string // Model ARN (empty when SUBMITTED)
Accuracy float64 // Training accuracy (0 when SUBMITTED)
Precision float64 // Training precision (0 when SUBMITTED)
Recall float64 // Training recall (0 when SUBMITTED)
F1Score float64 // Training F1 score (0 when SUBMITTED)
SamplesUsed int // Number of training samples
TrainingTime int // Training duration in seconds (0 when SUBMITTED)
Improvements []string // Improvements (empty when SUBMITTED)
}
TrainingResult holds the result of a training job submission