Learning a Collaboration Closeness Score for Coworker Pairs
Machine LearningModel answerLast updated
Design an ML system that scores how closely any two employees in an organization collaborate, covering signals, proxy labels, training, evaluation, privacy and serving.
You are building a collaboration closeness score d(a, b) for any two people in a company. A lower value means the two people work together more closely. No labeled "ground truth" for working closeness exists, so you must define the target yourself.
Walk through an end-to-end design as you would in an hour-long ML design discussion. Cover:
- Framing. Which product consumes the score (for example search ranking, people suggestions, or finding experts)? What does "closeness" mean precisely? Does the consumer need a true metric (symmetric, triangle inequality), or is a ranking score enough?
- Signals. Which data sources can you use (org chart, calendar metadata, document co-editing, comments and mentions, chat or email metadata)? How do you normalize them, and what privacy or permission limits apply?
- Modeling. Describe a simple graph-based baseline and a learned model. What proxy labels do you train on, and how do you split data in time to avoid leakage?
- Evaluation. How do you judge quality offline and online when real labels do not exist?
- Serving. How do you provide a score for every pair of employees without precomputing all N^2 distances? How do you handle new hires?
- Operations. How do you monitor drift and reorganizations?
State your assumptions about company size and freshness requirements up front.
Hints
Hint 1
Start by choosing a consumer. A score for ranking search results can be a loose, asymmetric-tolerant ranking function, while a score used for clustering teams may need metric properties.
Hint 2
Treat the problem as link prediction on a weighted interaction graph: hold out the most recent window of collaboration and check whether the score predicts who collaborates there. Remember to normalize edge weights so that a 200-person all-hands counts far less than a two-person review.
Hint 3
You do not need N^2 distances. Learn a low-dimensional embedding per person and compute distances on demand, using approximate nearest neighbors for top-k queries; for new hires, initialize from org-chart and team neighbors.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Framing
Assume the main consumer is search and suggestion ranking: when a person searches for documents or people, results tied to close collaborators should rank higher. That consumer needs a good ordering more than a calibrated number, so I would aim for a symmetric, non-negative score and treat the triangle inequality as nice to have, not required. If a later consumer needs clustering, an embedding with Euclidean or cosine distance gives metric-like behavior for free.
Definition of closeness: the expected amount of recent, meaningful, mutual interaction between two people. "Recent" implies time decay, "meaningful" implies normalizing by event size, and "mutual" implies symmetry.
Assumptions: companies of 1k to 100k employees, daily refresh is enough, and message content is off limits; only metadata and explicit artifact interactions are used.
2. Signals and normalization
| Signal | Why it helps | Normalization |
|---|---|---|
| Meetings (co-attendance) | Strong, common | Weight by 1/(attendees - 1) so large meetings count little; 1:1s count most |
| Document co-editing, comments, reviews | Direct work evidence | Weight by edit volume with a log or cap |
| Mentions and replies | Directed interaction | Symmetrize with min or mean of both directions |
| Chat or email metadata | Frequency of contact | Count thread participation, cap per day to resist spam |
| Org chart | Prior and cold start | Tree distance, same manager, same team |
Common transformations: exponential time decay (half-life of roughly 30 to 90 days, tuned), log scaling of counts, and per-person normalization (like TF-IDF or PMI) so that highly connected people such as executives or admins do not appear close to everyone.
Privacy and permissions: use only data the company has authorized; apply per-source opt-outs; never expose the raw score between two people in a way that reveals private meetings; aggregate and audit access; and honor document ACLs when the score influences search.
3. Modeling
Baseline (graph). Build a weighted undirected graph where an edge weight is the sum of decayed, normalized interactions across sources. Define distance as d = 1 / (1 + w) for direct edges and shortest-path or random-walk-based measures (personalized PageRank, Adamic-Adar, common neighbors) for pairs without direct edges. This is cheap, interpretable and a strong benchmark.
Learned model. Train a two-tower or graph neural embedding model (for example GraphSAGE or LightGCN style) where each person has a vector built from node features (team, role, location, tenure) plus neighborhood aggregation. Distance is 1 - cos(e_a, e_b) or the Euclidean distance. Train with a contrastive or BPR loss: positives are pairs that collaborate in the target window, negatives are sampled pairs (mix of random and hard negatives such as same-department pairs who did not collaborate).
Proxy labels: future collaboration. Use features and graph built from time window [t0, t1] and positives from (t1, t2]. This is link prediction. A secondary label can be the weighted intensity of future interaction for a regression or ranking objective.
Leakage control: split strictly by time, never randomly across edges. Make sure that the graph used for neighborhood aggregation excludes the label window. Also avoid features that directly encode the label, like a meeting that is the label event itself.
4. Evaluation
Offline:
- Ranking metrics on the held-out future window: recall@k and NDCG@k of true future collaborators among the top-k nearest people per user, against the graph baseline and the org-chart-only baseline.
- Slice analysis: new hires, remote versus co-located, small versus large teams, cross-functional pairs. Cross-team collaborators are where a learned model should beat the org chart.
- Sanity checks: symmetry, monotonicity (more interaction should not increase distance), and stability day over day.
Online:
- A/B test on the consumer: click-through or success rate of search results and suggestions, time to find, and acceptance of suggested people.
- Optional lightweight surveys ("is this person someone you work with?") to build a small human-labeled calibration set.
Caveat: future collaboration is a biased proxy. People may not collaborate in the future because of reorgs, not lack of closeness, and existing tools bias who interacts. Use the survey set to check the proxy.
5. Serving
Do not precompute N^2. For 100k employees, that is 10^10 pairs.
- Embeddings: store one vector per person (64 to 128 dims, about 100k x 128 x 4 bytes, roughly 50 MB). Compute
d(a, b)on demand in microseconds. - Top-k neighbors: build an ANN index (HNSW or ScaNN) for "closest people to X" queries, and cache neighbors for active users.
- Batch refresh: recompute the graph and embeddings nightly; stream incremental updates for strong events if freshness matters.
- Cold start: a new hire has no interactions, so initialize from org-chart neighbors (manager, team, onboarding buddy) and blend in observed interactions as they accumulate, for instance by a weight that grows with interaction count.
6. Monitoring and drift
- Track embedding drift, the distribution of distances, and ranking metrics on a rolling holdout.
- Detect reorganizations (sudden shifts in the org chart or interaction patterns); temporarily increase decay speed or retrain.
- Watch for feedback loops: if the score drives suggestions, it shapes future collaboration. Keep an exploration slice that is not influenced by the score.
Common mistakes
- Treating all meetings equally, so all-hands events dominate.
- Random edge splits that leak future information.
- Letting hub nodes (executives, assistants) look close to everyone.
- Promising a true metric when the consumer only needs ranking.
- Ignoring privacy, or using message content without authorization.
- Evaluating only against the org chart, which the model can trivially replicate.
Complexity summary
Training scales with edges and embedding size; serving a pair is O(d) for embedding dimension d; top-k with ANN is roughly O(log N) per query.