Foreign funds snapped a two-month selling streak of Taiwanese equities in May amid renewed optimism around artificial intelligence.

Overseas investors bought $2.7 billion of Taiwanese shares, according to Bloomberg-compiled data. That’s a turnaround from when they sold stocks in March and April as Taiwan Semiconductor Manufacturing Co. cautioned over persistent weakness in consumer markets and funds rotated to rival South Korea.

Sentiment in chip stocks has recovered globally following another bullish forecast from AI chipmaker Nvidia. Taiwan’s dominant position in the AI value chain will get another boost this week as tech giants gather on the island for its annual electronics showcase event.