BANGKOK (AP) — World shares retreated Friday, led by heavy losses in Japan and South Korea as traders sold to lock in gains from recent rallies in stocks related to artificial intelligence.In early European trading, Germany’s DAX gave up 0.8% to 24,793.58, while the CAC 40 in Paris lost 0.4% to 8,398.14. Britain’s FTSE 100 shed 0.4% to 10,490.62. The future for the S&P 500 lost 0.2% while that for the Dow Jones Industrial Average edged 0.2% higher. In Asia, Tokyo’s Nikkei 225 index shed 4.2% to 69,360.88 and the Kospi in Seoul plunged 5.8% to 8,411.21. Both recovered some ground lost earlier in the day.Hong Kong’s Hang Seng lost 1.8% to 22,667.13, while the Shanghai Composite index slipped 2.3% to 4,027.26.In Australia, the S&P/ASX 200 was an outlier, gaining 0.2% to 8,764.20. Taiwan’s Taiex gave up 3.6%. The wide swings in Tokyo and Seoul are typical of recent volatility in markets as investors react to the deluge of dollars heading into AI data centers and other investments. Shares in Japan and South Korea hit records this week and logged strong gains on Thursday after chipmakers Qualcomm and Micron Technology reported better than expected earnings.

In South Korea, market trends have been dominated by movements in stock in Samsung Electronics, the country’s biggest company, and chipmaker SK Hynix, which like Samsung is collaborating with Nvidia on artificial intelligence.