TopicGPT 사용하기

2024. 11. 21. 15:15오블완 챌린지

728x90

올해 4월쯤 Topic Modeling 연구를 조금 했었거든요.

BERTopic을 대체할게 뭐 없을까 하다가 LLM을 활용해서 Topic Modeling을 하는 논문을 발견했었어요.

당시에는 간단한 아이디어인데 나쁘지않네 정도로만 생각했는데,

글쎄 NAACL 2024에 등재되었네요..!

 

https://arxiv.org/abs/2311.01449

 

TopicGPT: A Prompt-based Topic Modeling Framework

Topic modeling is a well-established technique for exploring text corpora. Conventional topic models (e.g., LDA) represent topics as bags of words that often require "reading the tea leaves" to interpret; additionally, they offer users minimal control over

arxiv.org

 

근데 막상 본문을 다시 읽으니 왜 NAACL에 등재되었는지 알 것도 같았어요.

보통 논문을 읽다보면 생각보다 저자들이 디테일한 정보를 공개하지 않는 경우가 많거든요.

그래서 제가 그대로 따라해보려해도 같은 결과를 얻기 어려울 때가 많아요.

근데 이 논문은 Appendix가 17장.. One column이긴하지만 정말 대단하죠? (디테일이 살아있다 이거예요)

 

나중에 시간이 되면 Paper review에 조금 꼼꼼히 다뤄보고 싶긴한데.. 지금 이거 말고도 읽어야 할 논문이 산더미라

이번엔 methodology만 간략하게 소개하고 넘~어~ 갈게요.


 

3. Methodology

3.1 Stage1: Topic Generation

1) 전체 Corpus에서 일부 document 추출 / Example topics S 생성 (sample topic은 사람이 작성하는 것으로 추정됨)

- sample topic의 경우, 주제와 함께 주제에 대한 설명을 간결하게 작성

- 예) Trade: Mentions the exchange of capital, goods, and services

2) document가 작성된 s 중 하나에 맞으면, 해당 주제에 할당하고 아니면 새롭게  생성
- 이때, document를 전체 corpus로 하지 않는 것은 지나치게 많은 비용이 소요되기 때문

3) 생성된 주제를 정제

- Sentence-Transformer embedding을 활용해 주제별 유사도 0.5 이상인 것은 합침

- LLM을 활용해서 가까운 거리에 있는 주제들은 합침

- 발생이 적은 주제 (희소한 주제)는 제거

 

3.2 Stage2: Topic Assignment

1) 각 document를 생성된 주제에 할당

2) 주제에 할당할 때, 이유를 함께 기술하도록 시킴 → 모델이 보다 정확하게 주제를 선정하게 하는 역할을 함

- 예) A sample topic assignment is Agriculture: Mentions changes in agricultural export requirements (“...repeal of the agricultural export requirements...”) where “Agriculture” is the assigned topic label, followed by the topic description and a quote from the document enclosed within parentheses.

3) self-correction을 통해 잘못 할당된 주제에 대해 수정


 

https://github.com/chtmp223/topicGPT

 

GitHub - chtmp223/topicGPT: TopicGPT: A Prompt-Based Framework for Topic Modeling (NAACL'24)

TopicGPT: A Prompt-Based Framework for Topic Modeling (NAACL'24) - chtmp223/topicGPT

github.com

 

그래도 저자의 아이디어를 따라 그 과정을 구현하다보면 그냥 주제를 추출하는 것보다는 나름 정확도가 올라가는 것도 같은?

기분 탓이려나요?

728x90