File size: 525 Bytes
fba0152 | 1 2 3 4 5 6 7 8 9 10 11 12 | def extract_relevant_text(text):
"""
์ฃผ์ด์ง ํ
์คํธ์์ `[/INST]`๋ก ์์ํ๊ณ ์ข
๋ฃ ํ๊ทธ `</>` ์ด์ ๊น์ง์ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์.
"""
pattern = r"\[/INST\](.*?</)" # [/INST]๋ก ์์ํ๊ณ </> ์ด์ ๊น์ง์ ํ
์คํธ๋ฅผ ์ถ์ถ
match = re.search(pattern, text, re.DOTALL)
if match:
# `[/INST]` ์ดํ `</s>` ์ ๊น์ง์ ํ
์คํธ ๋ฐํ
return match.group(1).strip().replace("</", "")
else:
return "๋งค์นญ๋๋ ํ
์คํธ๊ฐ ์์ต๋๋ค."
|