swirl's picture
Upload config.py with huggingface_hub
88e6227 verified
"""
Two-Tower Configuration
Architecture constants for Isengard (User Tower) and Mordor (Wine Tower).
"""
# =============================================================================
# EMBEDDING DIMENSIONS
# =============================================================================
# Input embedding dimension (google-text-embedding-004)
EMBEDDING_DIM = 768
# Output vector dimensions for both towers (must match for dot product)
USER_VECTOR_DIM = 128
WINE_VECTOR_DIM = 128
# Hidden layer dimension
HIDDEN_DIM = 256
# =============================================================================
# CATEGORICAL FEATURES
# =============================================================================
# Feature list matching constants.py CATEGORICAL_FEATURES
CATEGORICAL_FEATURES = [
"color",
"type",
"style",
"climate_type",
"climate_band",
"vintage_band",
]
# Categorical feature vocabulary sizes (approximate, for one-hot encoding)
CATEGORICAL_VOCAB_SIZES = {
"color": 5, # red, white, rosé, orange, sparkling
"type": 4, # still, sparkling, fortified, dessert
"style": 10, # Natural, Organic, Biodynamic, etc.
"climate_type": 4, # cool, moderate, warm, hot
"climate_band": 4, # cool, moderate, warm, hot
"vintage_band": 4, # young, developing, mature, non_vintage
}
# Total categorical encoding dimension
CATEGORICAL_ENCODING_DIM = sum(CATEGORICAL_VOCAB_SIZES.values()) # ~31
# =============================================================================
# TRAINING PARAMETERS
# =============================================================================
TRIPLET_MARGIN = 0.2 # Margin for triplet loss
LEARNING_RATE = 1e-4
BATCH_SIZE = 32
POSITIVE_RATING_THRESHOLD = 4.0 # Ratings >= 4 are positive samples
# =============================================================================
# HUGGINGFACE INFERENCE
# =============================================================================
# Model ID on HuggingFace Hub (for model upload/download)
HF_MODEL_ID = "swirl/two-tower-recommender"
# Inference Endpoint URL is read from settings.HF_TWO_TOWER_ENDPOINT_URL
# API Token is read from settings.HF_API_TOKEN (same as CLIP)