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 "๋งค์นญ๋˜๋Š” ํ…์ŠคํŠธ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."