새소식

딥러닝, 머신러닝/프롬프트 엔지니어링

개발자를 위한 챗 GPT 프롬프트 엔지니어링 #4. Summarizing

  • -

이전 글

 

 

 

이번 내용은 요약 부분으로 많은 서비스에서 사용하고 있는 기능이다.

 

아래 글은 해외 유튜브 영상 번역 + 요약 서비스로 6개월 만에 월 1천만원 매출을 내고 있는 릴리스AI에 관한 내용이다. 6개월 전이면 이게 될까 하는 게 긴가민가 했을 것 같은데, 역시 가능성을 보고 바로 뛰어드는 것도 가장 좋은 것 같다. 하지만 이 시장이 chat GPT와 같은 API를 기반으로 하다 보니 모방이 쉬울 것 같다. 모방을 어떻게 막을지, 어떤 차별화 포인트를 가져갈 지가 가장 중요한 것 같다.

 

단 둘이서 시작해 6개월 만에 월 1천만원의 매출을 내는 AI 서비스

feat. 투자도, 유료 마케팅도 없이

maily.so

 

 

1. 요약

쇼핑몰 사이트에서 제품 리뷰를 보고 제품 부서에게 피드백을 줄 수 있도록 변환하는 프롬프트이다. 원래의 평은 번역하면 아래와 같다.

  • "to give feedback to the Product department" 문구를 통해 제품 부서에게 피드백을 줄 수 있도록 메시지를 구체화했다. 
  • "focusing on any aspects that mention feature or design of the product" 로 해당 제품의 기능 또는 디자인을 언급하는 게 있으면 뽑아달라고 요청했다. 이런 식으로 긴 글에서 필요한 부분만 꺼내서 볼 수 있는 게 큰 장점이 될 것 같다.
# 리뷰를 보고 제품 부서에게 피드백을 줄 수 있도록 수정 - 제품 관련 사항이 있으면 더 포커스
# 원래는 to the Product department 없음
prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site to give feedback to the \
Product deparmtment. 

Summarize the review below, delimited by triple 
backticks, in at most 30 words, and focusing on any aspects \
that mention feature or design of the product. 

Review: ```{prod_review}```
"""

response = get_completion(prompt)
print(response)

 

 

[결과]

  • "제품이 부드럽고, 귀엽다. 하지만 가격보단 비싼 것 같다." 라고 기능, 디자인에 대한 평가를 강조한다.
더보기

Panda plush toy is soft, cute, and has a friendly face. However, it's smaller than expected for the price. Arrived early.

 

 

2. 정보 추출 (HTML에서 해보기, 크롤링 chat gpt 응용)

HTML 형식이 일관되게 되어 있지 않아 크롤링이 어려운 경우가 있다. 이 때 Chat GPT(LLM)를 사용하면 해결할 수 있다. 

 

html = '''
<td class="detailTable" valign="top">
                    <div id="dev-template-v2-root" class="tempate-detailed-summary-root pc dev-case-type case3" style="">
    <div class="detailed-summary-header">
        <div class="header-wrap dev-case-type case3" style="display: flex;">
            <div class="header">
                <div class="corp-name dev-corp-name" style="display: block;"><p><b style="font-size: 48px;"><span style="font-family: 굴림, Gulim; color: rgb(0, 158, 37);">[KT알파/보라매병원역/자체직전환]&nbsp;</span></b></p></div><div class="subtitle"><p><b><span style="font-family: 굴림, Gulim; color: rgb(0, 158, 37);">컨텐츠 편성 정보입력 (단순사무) 채용</span></b><br></p></div></div></div>
    </div>
    <div class="detailed-summary-contents">
        <div class="detailed-summary-content" id="dev-template-v2-part">
            <table class="content-table">
                <tbody>
                    <tr>
                        <td><p class="heading"><i class="icon-header dev-case-type case3"></i>포지션 및 자격요건</p></td>
                    </tr>
                </tbody>
            </table>
            <div class="recruitment">
                <table class="__se_tbl __se_tbl_noresize dev-list-type type-list">
                    <tbody> 
                        <tr>
                            <td class="header"><p><b>사무보조 </b><br class="default">( ○명 ) </p></td>
                            <td class="">
                                <div class="recruitment-items">
                                    <div class="recruitment-item">
                                        <table class="content-table"><tbody><tr><td><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 14pt;">
                                                        </span><p><b><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 14pt;">담당업무</span></b></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">
                                                        </span><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ</span><span style="color: rgb(53, 53, 53); font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; text-align: center; font-size: 12pt;">지니TV (IPTV/OTT) 음악/다큐/애니메이션 장르편성</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ</span><span style="color: rgb(53, 53, 53); text-align: center; letter-spacing: 0px;">월정액 장르편성</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ키즈/교육 편성&nbsp;</span><span style="color: rgb(53, 53, 53); text-align: center; letter-spacing: 0px;">&nbsp;</span></p><p>&nbsp;* 위 부서중 면접 후 장르 배치 예정</p><p><br></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">
                                                        



                                                        </span><p><b><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 14pt;">근무조건</span></b></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt; color: rgb(53, 53, 53); letter-spacing: normal;">근무기간: 1년이상 <span style="color: rgb(255, 0, 0);">(1년이후 평가에 따라 자체직(계약직) 전환가능)</span></span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt; color: rgb(53, 53, 53); letter-spacing: normal;">근무요일: 월~금</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt; color: rgb(53, 53, 53); letter-spacing: normal;">근무시간: 09:00~18:00/휴게시간 60분&nbsp;</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt; color: rgb(53, 53, 53); letter-spacing: normal;">급여조건: 210만원~240만원(세전, 경력에 따라 차등지급)</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt; color: rgb(53, 53, 53); letter-spacing: normal;">복리후생: <span style="color: rgb(58, 50, 195);">4</span><span style="color: rgb(58, 50, 195);">대보험, 조식제공, 연차, 리플래쉬휴가7일(연차별도), 명절선물, 경조휴가</span></span></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">

                                                        
                                                        
                                                        </span><p><br></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">
                                                        </span><p><b><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 14pt;">우대사항</span></b></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">
    </span><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ인근거주자</span></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">
    </span><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ유관업무 경력자&nbsp;</span></p><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">ㆍ장기근무자 우대</span><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF; font-size: 12pt;">&nbsp;</span></p><p><br></p>
                                                        
                                                        
                                                        

                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        
                        
                    </tbody>
                </table></div></div>
        <div class="detailed-summary-content">
            <div class="content">
                <table class="content-table">
                    <tbody>
                        <tr>
                            <td>
                                <p class="heading"><i class="icon-header dev-case-type case3"></i>전형절차</p>
                                <p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ서류전형&nbsp;&gt;&nbsp;1차면접&nbsp;&gt; 최종합격</span></p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">
                                </span><p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ면접일정은 추후 통보됩니다.</span></p><p><br></p></td></tr></tbody></table></div></div>
        <div class="detailed-summary-content">
            <div class="content">
                <table class="content-table">
                    <tbody>
                        <tr>
                            <td>
                                <p class="heading"><i class="icon-header dev-case-type case3"></i>유의사항</p>
                                <p><span style="font-family: 나눔바른고딕, NanumBarunGothic, NanumBarunGothicOTF;">ㆍ허위사실이 발견될 경우 채용이 취소될 수 있습니다.</span></p>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <p><br></p>
    </div>
</div>

                                                                                                                                                                                                
                </td>
'''

prompt = f"""
Your task is to extract detail information from job description html.\
The detail informations are role, responsiblities, preferred qualifications and candidate requirements.

Extract detail information from the html below, delimited by triple 
backticks. 

Provide them in JSON format with the following keys: 
role, responsiblities, preferred_qualifications, and candidate_requirements.

JD: ```{html}```
"""

response = get_completion(prompt)
print(i, response, "\n")

 

[결과]

더보기

json
{
    "role": "사무보조",
    "responsiblities": "지니TV (IPTV/OTT) 음악/다큐/애니메이션 장르편성, 월정액 장르편성, 키즈/교육 편성, 면접 후 장르 배치 예정",
    "preferred_qualifications": "인근거주자, 유관업무 경력자, 장기근무자 우대",
    "candidate_requirements": "근무기간: 1년이상 (1년이후 평가에 따라 자체직(계약직) 전환가능), 근무요일: 월~금, 근무시간: 09:00~18:00/휴게시간 60분, 급여조건: 210만원~240만원(세전, 경력에 따라 차등지급), 복리후생: 4대보험, 조식제공, 연차, 리플래쉬휴가7일(연차별도), 명절선물, 경조휴가"
}

 

잡코리아 공고에서 "detailTable" 하위 태그를 복사한 건데 나름 그럴 듯한 결과가 나온다. 채용 공고가 회사별로 제각각 쓰는 거라 형식이 다 달라서 크롤링이 힘든데 chatGPT로 가능한 걸 보니 많은 도움이 될 것 같다. 현재 잡코리아나 사람인은 API에서도 상세 사항(업무, 우대사항 등)을 제공하지 않고 있다. 그 부분은 chatGPT 3.5로도 해결 가능하니 필요한 경우 저비용으로도 유용하게 쓸 수 있을 것 같다. (위의 결과는 gpt 3.5 실행 결과임)

 

3. 감정 분류

별도 모델 학습 없이도 바로 해당 문장이 긍정적인지, 부정적인지 분류 가능하다. 보안 등 다양한 분야에 응용할 수 있을 것 같다.

# 후처리 쉽게 하기 위해 긍정, 부정으로만 출력
prompt = f"""
What is the sentiment of the following product review, 
which is delimited with triple backticks?

Give your answer as a single word, either "positive" \
or "negative".

Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

 

결과

더보기

Positive

 

고객 리뷰를 보고 화가 나있는지 분류 : 

prompt = f"""
Is the writer of the following review expressing anger?\
The review is delimited with triple backticks. \
Give your answer as either yes or no.

Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

 

 

생각보다 알려지지 않은 부분들도 시도하다 보면 많이 찾을 수 있을 것 같다. 그러면 알고리즘으로 풀기 어려운 문제들도 많이 해결할 수 있을 것 같다. 다음부터는 알고리즘에서 막히더라도 한번 시도해봐야겠다.

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.