Hekir
I embedded the business descriptions of 499 S&P 500 companies and took each firm’s ten nearest neighbors as its peers. Their daily returns correlate with the firm’s at 0.335 on average, against 0.275 for its GICS sector peers (difference +0.060, 95% CI 0.050 to 0.069, 493 firms).
- Python
- sentence-transformers
- all-MiniLM-L6-v2
- NumPy
- SciPy
- pandas
- UMAP
- Qdrant (optional)
Picking a company’s peers is a routine step in valuation, pairs trading, index construction and risk modeling, and the default answer is GICS: one sector per firm, assigned mainly by its largest source of revenue. I tested a text-based alternative. The universe is the S&P 500 as of June 2026: 502 listings, or 499 companies after merging dual share classes. Each firm’s yfinance business summary is embedded with all-MiniLM-L6-v2, a 384-dimension model that runs locally with no API. 58.5% of the summaries are longer than the model’s 256-token window, so I split them into chunks, embedded each one and averaged the vectors. A firm’s peers are its ten nearest neighbors by exact cosine similarity in NumPy; as a check, I loaded the vectors into Qdrant and confirmed it returns identical neighbor lists.
The main result is about returns. Over 2025-07-01 to 2026-06-30, a firm’s mean daily-return correlation with its ten embedding peers is 0.335, against 0.275 with its GICS sector peers (difference +0.060, 95% CI 0.050 to 0.069, tested with a sign-flip permutation test and a bootstrap over firms). The embedding peers are the more correlated set for 72% of the 493 firms with enough price history, and net of the market the gap is +0.070 (95% CI 0.060 to 0.080). Two thirds of embedding peers are in the firm’s own sector, so this mostly reflects the embeddings picking the closest firms within a sector. I didn’t compare against GICS sub-industry peers, which would be the stricter test.
The embeddings also recover the sectors without being told what they are: 66.0% of nearest neighbors share the firm’s GICS sector, against 11.0% expected by chance (6.0×), tested against 10,000 firm-label permutations with Benjamini–Hochberg correction. Once sector size is accounted for, Utilities (14.9×) and Energy (14.8×) are the tightest sectors, and Industrials (3.5×) and Consumer Discretionary (3.6×) the loosest. Six cross-sector links are above chance, the strongest Energy → Utilities (3.7×).
Firms whose neighbors mostly sit in another sector (83 of them at a 0.7 threshold) show no co-movement advantage: −0.014 (95% CI −0.036 to 0.010). The embeddings give a finer peer set inside the GICS frame; they don’t show that GICS puts particular firms in the wrong sector.




