s = (
    "hi hi hi hi some words words words which'll repeat repeat repeat repeat repeat"
    )
m = regex.sub('(?<= |^)(\\S+)(?: \\1){2,}(?= |$)', '\\1 \\1', s)
m
regex for repeating words in a string in Python