וְעֹ֤֥שֶׂה חֶ֖֙סֶד֙ לַֽאֲלָפִ֑֔ים לְאֹהֲבַ֖י וּלְשֹׁמְרֵ֥י מצותו [מִצְוֺתָֽי׃] (ס)
나를 사랑하고 내 계명을 지키는 자에게는 천대까지 은혜를 베푸느니라
Rashi
לאלף דור TO A THOUSAND GENERATIONS — But elsewhere (5:10) it states: to thousands of generations! The explanation is: Here where it is connected with (refers to) "those who keep His commandments" it states that God's grace is extended to a thousand generations; but there where it is associated with "those who love Him" it states that it is extended to thousands of generations (Sotah 31a);
Siftei Chakhamim
But below it states: “For thousands of generations,” etc. In other words: Those who keep His commandments out of fear [are rewarded] for a thousand generations, and those who do so out of love [are rewarded] for two thousand generations. Even though it is also written here, “those who love Him,” before, “those who keep His commandments,” One may say: “Those who love Him” is connected to the previous phrase, “Who keeps the covenant and the kindliness.” And, “Those who keep,” is connected to the phrase written afterwards. Likewise above (5:10) it is written, “two thousand,” and it is also written, “for those who guard.” There also, the answer is similar: “For those who love,” is connected to the phrase preceding it, which is, “For two thousand.” And “For those who keep,” [are rewarded] for a thousand generations.