Skip to main content

Context Pipeline

The Context Pipeline is PriveTag’s system for understanding user needs and providing relevant recommendations.

The 8 Golden Points

We capture 8 key data points that drive recommendation quality:

1. Travel Type

Family, couple, solo, business, friends

2. Nationality

Cultural preferences and language

3. Interests

Activities user enjoys

4. Budget

Spending preferences

5. Age Group

Activity difficulty matching

6. Location

Current or target area

7. Weather

Real-time conditions

8. Time

Time of day relevance

Pipeline Architecture

Data Flow Example

Input: API Request

{
  "user_profile": {
    "travel_type": "family",
    "nationality": "KR",
    "interests": ["theme-park", "zoo"],
    "budget": "mid"
  },
  "location": {
    "city": "Bangkok",
    "lat": 13.7563,
    "lon": 100.5018
  },
  "limit": 5
}

Step 1: Enrichment

The pipeline enriches the request with external data:
{
  "weather": {
    "condition": "sunny",
    "temperature": 32,
    "humidity": 65,
    "is_outdoor_suitable": true
  },
  "time_context": {
    "local_time": "14:30",
    "day_period": "afternoon",
    "is_weekend": true
  }
}

Step 2: Ground Truth Lookup

Query historical data for similar profiles:
-- What did Korean families actually visit in Bangkok?
SELECT activity_id, COUNT(*) as visits
FROM ground_truth
WHERE travel_type = 'family'
  AND nationality = 'KR'
  AND city = 'Bangkok'
  AND is_verified = TRUE
GROUP BY activity_id
ORDER BY visits DESC

Step 3: Scoring

Each activity is scored on multiple factors:
FactorWeightSafari WorldDream WorldNight Market
Profile Match30%28/3025/3015/30
Ground Truth25%24/2520/2510/25
Weather Match20%18/2018/2012/20
Time Match15%14/1514/158/15
Budget Match10%9/109/1010/10
Total100%938655

Step 4: Output

{
  "recommendations": [
    {
      "id": "act_safari",
      "title": "Safari World Bangkok",
      "relevance_score": 93,
      "recommendation_reason": "Top choice for Korean families - verified visits"
    },
    {
      "id": "act_dream",
      "title": "Dream World",
      "relevance_score": 86,
      "recommendation_reason": "Family-friendly theme park for afternoon"
    }
  ],
  "context": {
    "log_id": "ctx_abc123",
    "user_profile_summary": "Korean family, theme-park & zoo interests, mid budget",
    "environment_summary": "Bangkok, sunny 32°C, Saturday afternoon"
  }
}

Scoring Factors Explained

1. Profile Match (30%)

How well does the activity match user preferences?
User AttributeMatching Logic
travel_typeFamily → kid-friendly activities
interestsDirect category match
budgetPrice range alignment
age_groupActivity difficulty level

2. Ground Truth (25%)

Real visit data from similar users:
Ground Truth Scoring: Activities that similar profiles actually visited (and verified via NFC/QR) get higher scores than those only booked.
Score = (verified_visits / total_recommendations) * 25

3. Weather Match (20%)

Real-time weather appropriateness:
ConditionIndoor ActivitiesOutdoor Activities
Sunny, < 35°C15/2020/20
Sunny, > 35°C18/2010/20
Rainy20/205/20
Overcast17/2018/20

4. Time Match (15%)

Activity timing relevance:
Time PeriodBest Activities
Morning (6-11)Tours, outdoor, breakfast spots
Afternoon (11-17)Theme parks, museums, malls
Evening (17-21)Dinner, shows, sunset activities
Night (21+)Nightlife, late dining

5. Budget Match (10%)

Price alignment with stated budget:
budget: "budget"  → Activities < 500 THB score highest
budget: "mid"     → Activities 500-2000 THB score highest
budget: "luxury"  → Activities > 2000 THB score highest

Context Logging

Every recommendation request creates a context log:
{
  "log_id": "ctx_abc123",
  "created_at": "2025-12-10T14:30:00Z",
  "input": {
    "user_profile": { /* ... */ },
    "location": { /* ... */ }
  },
  "enriched": {
    "weather": { /* ... */ },
    "time_context": { /* ... */ }
  },
  "ground_truth_matches": 45,
  "recommended_activities": ["act_safari", "act_dream", "act_sea"],
  "scores": {
    "act_safari": 93,
    "act_dream": 86,
    "act_sea": 78
  }
}

Why Context Logging Matters

When a user later books and visits an activity: This feedback loop is what makes PriveTag’s recommendations improve over time.

Customization Options

Filters

Override automatic scoring with explicit filters:
{
  "filters": {
    "is_indoor": true,      // Force indoor only
    "max_price": 2000,      // Price ceiling
    "categories": ["spa"],  // Specific categories
    "difficulty": "easy"    // Activity intensity
  }
}

Boosting

Boost specific factors for the request:
{
  "scoring_weights": {
    "ground_truth": 0.4,    // Increase GT weight from 25% to 40%
    "weather": 0.1          // Decrease weather weight from 20% to 10%
  }
}

Performance

MetricValue
Average Processing Time< 200ms
Weather API Cache TTL15 minutes
Ground Truth Query Cache1 hour
Max Concurrent Requests1000/sec

Best Practices

Location coordinates enable weather-aware recommendations. Without them, we default to city-level weather which may be less accurate.
More context = better recommendations. Even if optional, providing nationality, age_group, and budget significantly improves relevance.
Pass the log_id when booking to complete the feedback loop. This is how Ground Truth data improves over time.
Let the scoring algorithm work. Excessive filters can eliminate good options that would score highly.

Next Steps