This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
"""Phase 2: Semantic 매칭용 모델 다운로드"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import urllib.request
|
||||
import zipfile
|
||||
|
||||
MODELS_DIR = Path(r"d:\ad-hoc\kei\design_agent\models")
|
||||
MODELS_DIR.mkdir(exist_ok=True)
|
||||
|
||||
|
||||
def download_ko_sroberta():
|
||||
"""ko-sroberta-multitask (Sentence-BERT, 420MB)
|
||||
sentence-transformers 라이브러리가 자동 캐시에 다운로드"""
|
||||
print("\n=== [1/3] ko-sroberta-multitask 다운로드 ===")
|
||||
from sentence_transformers import SentenceTransformer
|
||||
model = SentenceTransformer('jhgan/ko-sroberta-multitask',
|
||||
cache_folder=str(MODELS_DIR / "sentence-transformers"))
|
||||
print(f"✓ 완료: 차원 {model.get_sentence_embedding_dimension()}")
|
||||
return model
|
||||
|
||||
|
||||
def download_korean_fasttext():
|
||||
"""Korean FastText — Kyubyong 공개 모델 (100~200MB)
|
||||
GitHub releases: https://github.com/Kyubyong/wordvectors"""
|
||||
print("\n=== [2/3] Korean FastText 다운로드 ===")
|
||||
# Kyubyong의 한국어 FastText 200차원 (약 400MB)
|
||||
target = MODELS_DIR / "ko_fasttext"
|
||||
target.mkdir(exist_ok=True)
|
||||
model_file = target / "ko.bin"
|
||||
if model_file.exists():
|
||||
print(f"✓ 이미 존재: {model_file}")
|
||||
return str(model_file)
|
||||
# Facebook pre-trained FastText로 대체 - huggingface hub 사용
|
||||
try:
|
||||
from huggingface_hub import hf_hub_download
|
||||
print(" HuggingFace에서 한국어 FastText 다운로드...")
|
||||
path = hf_hub_download(
|
||||
repo_id="facebook/fasttext-ko-vectors",
|
||||
filename="model.bin",
|
||||
cache_dir=str(MODELS_DIR / "fasttext"),
|
||||
)
|
||||
print(f"✓ 완료: {path}")
|
||||
return path
|
||||
except Exception as e:
|
||||
print(f" HuggingFace 실패: {e}")
|
||||
# 대안: ko-sroberta만 써서 FastText 역할 커버
|
||||
print(" → Korean FastText는 skip하고 ko-sroberta로 대체")
|
||||
return None
|
||||
|
||||
|
||||
def download_korean_word2vec():
|
||||
"""Korean Word2Vec — gensim 데이터나 HF에서 받기"""
|
||||
print("\n=== [3/3] Korean Word2Vec 다운로드 ===")
|
||||
# 작은 공개 모델 시도
|
||||
try:
|
||||
from huggingface_hub import hf_hub_download
|
||||
path = hf_hub_download(
|
||||
repo_id="Kyubyong/wordvectors-ko",
|
||||
filename="ko.bin",
|
||||
cache_dir=str(MODELS_DIR / "word2vec"),
|
||||
)
|
||||
print(f"✓ 완료: {path}")
|
||||
return path
|
||||
except Exception as e:
|
||||
print(f" 실패: {e}")
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sroberta = download_ko_sroberta()
|
||||
fasttext = download_korean_fasttext()
|
||||
w2v = download_korean_word2vec()
|
||||
print("\n=== 다운로드 결과 ===")
|
||||
print(f"ko-sroberta: {'✓' if sroberta else '✗'}")
|
||||
print(f"FastText: {'✓' if fasttext else '✗'}")
|
||||
print(f"Word2Vec: {'✓' if w2v else '✗'}")
|
||||
Reference in New Issue
Block a user