Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 5.45 KB

File metadata and controls

38 lines (29 loc) · 5.45 KB

StageDefsLearnedFusionConfig

Configuration for learned fusion with bandit-based weight optimization. Enables personalized feature weighting by learning from user interactions. The system learns which features (text, image, audio, etc.) matter most for different users or contexts. ┌─────────────────────────────────────────────────────────────────────────────┐ │ HOW LEARNED FUSION WORKS │ ├─────────────────────────────────────────────────────────────────────────────┤ │ 1. Query arrives with context (user_id, segment, etc.) │ │ 2. Look up bandit state for this context │ │ 3. Sample feature weights from Beta distributions │ │ 4. Execute separate queries per feature with learned weights │ │ 5. Fuse results using sampled weights │ │ 6. On feedback (click), update bandit for relevant features │ └─────────────────────────────────────────────────────────────────────────────┘ Cold Start Handling: - NEW users: Uses demographic context (user_segment, device_type) - Returning users: Uses personal context after min_interactions - Fallback: Global context as ultimate fallback Requirements: - Interactions API must be called with feedback (clicks, etc.) - Context features should be passed in query inputs Example: python LearnedFusionConfig( algorithm=LearningAlgorithm.THOMPSON_SAMPLING, context_features=[\"INPUT.user_id\"], demographic_features=[\"INPUT.user_segment\", \"INPUT.device_type\"], reward_signal=\"click\", min_interactions=5, )

Properties

Name Type Description Notes
algorithm StageDefsLearningAlgorithm Learning algorithm for weight optimization. THOMPSON_SAMPLING (default): Beta-Bernoulli bandit with natural exploration. Works immediately, no tuning needed, best for most use cases. [optional]
context_features List[str] Template variables for personal context (e.g., ['INPUT.user_id']). Empty list = global learning (same weights for all users). Personal context is used after user has min_interactions. Supports: INPUT., CONTEXT., etc. [optional]
demographic_features List[str] Template variables for demographic fallback context. Used for NEW users with < min_interactions. Enables cold start by learning from similar user segments. Examples: INPUT.user_segment, INPUT.device_type, INPUT.country. [optional]
fallback_strategy str Strategy when user lacks sufficient history. 'hierarchical': Try personal → demographic → global (recommended). 'global': Skip demographic, fall back directly to global. [optional] [default to 'hierarchical']
min_interactions int Minimum interactions before using personal context. Below this threshold, uses demographic or global context. Prevents overfitting to small samples. Typical range: 3-10. [optional] [default to 5]
reward_signal str Interaction type(s) that count as positive reward. Single: 'click', 'purchase', 'positive_feedback'. Multiple: 'click,purchase' (comma-separated). Determines when to strengthen feature weights. [optional] [default to 'click']
exploration_bonus float Controls exploration vs exploitation balance. 1.0 = balanced (default). Higher = more exploration (try diverse weights). Lower = more exploitation (use known winners). Typical range: 0.5-2.0. [optional] [default to 1]
prior_alpha float Beta distribution prior for positive feedback (α). 1.0 = uniform prior (no initial bias). Higher = initial belief that features are effective. [optional] [default to 1]
prior_beta float Beta distribution prior for negative feedback (β). 1.0 = uniform prior (no initial bias). Higher = initial belief that features are ineffective. [optional] [default to 1]

Example

from mixpeek.models.stage_defs_learned_fusion_config import StageDefsLearnedFusionConfig

# TODO update the JSON string below
json = "{}"
# create an instance of StageDefsLearnedFusionConfig from a JSON string
stage_defs_learned_fusion_config_instance = StageDefsLearnedFusionConfig.from_json(json)
# print the JSON string representation of the object
print(StageDefsLearnedFusionConfig.to_json())

# convert the object into a dict
stage_defs_learned_fusion_config_dict = stage_defs_learned_fusion_config_instance.to_dict()
# create an instance of StageDefsLearnedFusionConfig from a dict
stage_defs_learned_fusion_config_from_dict = StageDefsLearnedFusionConfig.from_dict(stage_defs_learned_fusion_config_dict)

[Back to Model list] [Back to API list] [Back to README]