EcomGen-Series
Collection
Generation model for text generation and e-commerce business items • 5 items • Updated
How to use UICHEOL-HWANG/EcomGen-0.0.1v with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="UICHEOL-HWANG/EcomGen-0.0.1v") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("UICHEOL-HWANG/EcomGen-0.0.1v")
model = AutoModelForCausalLM.from_pretrained("UICHEOL-HWANG/EcomGen-0.0.1v", device_map="auto")How to use UICHEOL-HWANG/EcomGen-0.0.1v with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "UICHEOL-HWANG/EcomGen-0.0.1v"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UICHEOL-HWANG/EcomGen-0.0.1v",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/UICHEOL-HWANG/EcomGen-0.0.1v
How to use UICHEOL-HWANG/EcomGen-0.0.1v with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "UICHEOL-HWANG/EcomGen-0.0.1v" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UICHEOL-HWANG/EcomGen-0.0.1v",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "UICHEOL-HWANG/EcomGen-0.0.1v" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UICHEOL-HWANG/EcomGen-0.0.1v",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use UICHEOL-HWANG/EcomGen-0.0.1v with Docker Model Runner:
docker model run hf.co/UICHEOL-HWANG/EcomGen-0.0.1v
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("UICHEOL-HWANG/EcomGen-0.0.1v")
model = AutoModelForCausalLM.from_pretrained("UICHEOL-HWANG/EcomGen-0.0.1v", device_map="auto")모델 개요
이 모델은 EleutherAI의 polyglot-ko-1.3b를 기반으로 fine-tuning된 상품설명 생성 모델입니다. 상품명을 입력으로 받아 해당 상품에 대한 상세한 설명을 자동으로 생성합니다.
주요 특징
기반 모델: EleutherAI의 polyglot-ko-1.3b
fine-tuning 데이터: 다양한 카테고리의 상품명과 상품설명 페어 데이터
입력: 상품명
출력: 생성된 상품설명
언어: 한국어
사용방법
from transformers import AutoTokenizer, AutoModelForCausalLM
def load_model(model_path):
""" ✅ 학습된 모델과 토크나이저 로드 """
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path)
model.eval()
return tokenizer, model
def generate_description(model, tokenizer, product_name, max_length=512):
""" ✅ 상품명에 대한 설명을 생성하는 함수 """
# ✅ EOS 토큰 설정
eos_token = tokenizer.eos_token or tokenizer.pad_token or "<|endoftext|>"
stop_token_id = tokenizer.eos_token_id or tokenizer.pad_token_id or \
tokenizer.encode(eos_token, add_special_tokens=False)[0]
# ✅ 훈련된 데이터 패턴에 맞춘 프롬프트
prompt = f"상품명: {product_name}\n상품 설명: "
# ✅ 토큰화 및 입력값 변환
inputs = tokenizer(prompt, return_tensors="pt")
inputs.pop("token_type_ids", None)
# ✅ 생성 실행
output = model.generate(
**inputs,
max_new_tokens=max_length,
repetition_penalty=1.15, # ✅ 반복 방지
temperature=1.0, # ✅ 창의성 조절
top_p=0.9, # ✅ 다양한 응답 생성
top_k=40, # ✅ 확률적으로 상위 50개 단어 중 선택
do_sample=True, # ✅ 샘플링 활성화 (중요!)
pad_token_id=stop_token_id, # ✅ 패딩 시 EOS 토큰 적용
eos_token_id=stop_token_id, # ✅ EOS 토큰 적용
)
# ✅ 결과 디코딩
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
return generated_text
if __name__ == "__main__":
""" ✅ 메인 실행 함수 """
model_path = "UICHEOL-HWANG/EcomGen-0.0.1v" # ✅ 학습된 모델 경로
tokenizer, model = load_model(model_path)
# ✅ 테스트할 상품명 입력
product_name = "김갑생할머니김"
description = generate_description(model, tokenizer, product_name)
print("\n=== 생성된 상품 설명 ===\n")
print(description)
Base model
EleutherAI/polyglot-ko-1.3b
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UICHEOL-HWANG/EcomGen-0.0.1v")