728x90
SMALL
🐹 LLM 옵션
Open Source LLM (상업적 사용 가능)
- Hugging Face에서 제공하는 모델
- Falcon-7B, Falcon-40B
- UAE의 Technology Innovation Institute에서 제공하는 LLM으로, 상업적 이용이 허용된 Apache 2.0 라이선스를 사용.
- 사용 예시: 자연어 텍스트에서 키워드 추출을 위한 대규모 언어 모델.
from transformers import pipeline model = pipeline("text-generation", model="tiiuae/falcon-7b") prompt = "Extract keywords from the following text: 'This document explains the importance of data privacy and GDPR compliance in modern applications.'" response = model(prompt) print(response)
- Falcon-7B, Falcon-40B
- GPT-J or GPT-NeoX (EleutherAI)
- EleutherAI가 공개한 모델로, Apache 2.0 라이선스.
- 적합성: 큰 데이터로 학습되어 자연어 이해 및 생성에 강점.
- 키워드 추출처럼 간단한 작업에도 적합.
- LLaMA (Meta)
- 상업적 사용을 위해 LLaMA 2 Community License에 따라 활용 가능.
- 적합성: 고성능 모델로 다양한 언어 태스크에서 활용.
- BLOOM (BigScience)
- Apache 2.0 라이선스로 공개된 대규모 멀티언어 모델.
- 적합성: 여러 언어로 된 텍스트에서 키워드 추출 가능.
🐹 키워드 추출 방법론
- Zero-shot Prompting
LLM에 직접적으로 키워드 추출을 지시: - "Extract the top 5 keywords from this text: [텍스트]"
- Few-shot Prompting
몇 가지 예제를 제공하여 모델의 정확도를 높임: - "Extract keywords from this text based on these examples: Example 1: 'This paper discusses AI and machine learning' -> ['AI', 'machine learning'] Example 2: 'Understanding cloud computing and its applications' -> ['cloud computing', 'applications'] Input: [텍스트]"
- Post-processing with Token Models
- LLM이 추출한 키워드를 후처리하여 NER이나 TF-IDF 같은 방식으로 정제.
- 예: Hugging Face의 NER 파이프라인:
from transformers import pipeline ner_pipeline = pipeline("ner", model="dbmdz/bert-large-cased-finetuned-conll03-english") text = "This document explains the importance of data privacy and GDPR compliance." entities = ner_pipeline(text) keywords = [ent['word'] for ent in entities if ent['entity'] == 'I-NP'] print(keywords)
🐹 특화된 키워드 추출 도구
- KeyBERT
- BERT 기반의 키워드 추출 도구.
- 오픈소스이며 상업적 사용 가능.
- 간단한 구현:
from keybert import KeyBERT kw_model = KeyBERT() keywords = kw_model.extract_keywords("This document explains the importance of data privacy and GDPR compliance.") print(keywords)
- spaCy + Transformer
- Named Entity Recognition (NER) 또는 Tokenization을 통해 중요한 키워드 식별:
import spacy nlp = spacy.load("en_core_web_trf") doc = nlp("This document explains the importance of data privacy and GDPR compliance.") keywords = [ent.text for ent in doc.ents] print(keywords)
- Named Entity Recognition (NER) 또는 Tokenization을 통해 중요한 키워드 식별:
- Haystack (RAG Framework)
- Haystack의 PreProcessor 모듈로 텍스트에서 키워드를 추출하고 검색에 활용 가능.
- 상업적 사용 가능:
from haystack.nodes import PreProcessor processor = PreProcessor(split_by="word", split_length=200, split_respect_sentence_boundary=True) documents = processor.process([{"content": "This document explains the importance of data privacy and GDPR compliance."}]) print(documents)
🐹 추천 조합
- LLM + KeyBERT: LLM으로 초기 키워드를 생성하고 KeyBERT로 스코어링.
- LLM + Haystack: RAG와 자연스럽게 통합 가능.
- LLM 단독: Falcon-7B, BLOOM 같은 모델로 간단한 작업 수행.
🐹 LLM 선택 요약
모델 라이선스 특징 상업적 사용
Falcon-7B | Apache 2.0 | 고성능, 적은 리소스 필요 | 가능 |
GPT-NeoX | Apache 2.0 | 대규모 언어 모델, 강력한 지원 | 가능 |
BLOOM | Apache 2.0 | 멀티언어 지원 | 가능 |
LLaMA 2 | Community License | 높은 성능, 다양한 작업 가능 | 가능 |
728x90
LIST
'Internship' 카테고리의 다른 글
[OpenWebUI] Pipeline 연결 (0) | 2024.12.20 |
---|---|
[OpenWebUI] LLM 웹 인터페이스 (1) | 2024.12.20 |
vLLM : LLM 추론 프레임워크 (0) | 2024.11.26 |
RAG란? (0) | 2024.11.24 |
Elasticsearch란? (0) | 2024.11.19 |