HAERAE-HUB/KOREAN-WEBTEXT
Viewer • Updated • 1.28M • 472 • 46
How to use idah4/etm-korean-tiny with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="idah4/etm-korean-tiny", trust_remote_code=True) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("idah4/etm-korean-tiny", trust_remote_code=True, dtype="auto")How to use idah4/etm-korean-tiny with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "idah4/etm-korean-tiny"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "idah4/etm-korean-tiny",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/idah4/etm-korean-tiny
How to use idah4/etm-korean-tiny with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "idah4/etm-korean-tiny" \
--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": "idah4/etm-korean-tiny",
"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 "idah4/etm-korean-tiny" \
--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": "idah4/etm-korean-tiny",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use idah4/etm-korean-tiny with Docker Model Runner:
docker model run hf.co/idah4/etm-korean-tiny
소형 텍스트 디코더 LM
# %% ETM Inference
import torch
from transformers import AutoModelForCausalLM
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/polyglot-ko-1.3b")
# 1️⃣ 모델 로드
repo_id = "idah4/etm-korean-tiny"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForCausalLM.from_pretrained(
repo_id,
trust_remote_code=True
).to(device).eval()
def encode(text):
return torch.tensor(
tokenizer(text)["input_ids"],
dtype=torch.long
).unsqueeze(0).to(device)
def decode(ids):
return tokenizer.decode(ids.tolist(), skip_special_tokens=True)
# 3️⃣ 텍스트 생성 함수
@torch.no_grad()
def generate_text(prompt: str,
temperature=0.8,
top_k=40,
top_p=0.95,
repetition_penalty=2.0,
max_new_tokens=100,):
input_ids = encode(prompt)
out = model.generate(
input_ids,
max_new_tokens=max_new_tokens,
temperature=temperature,
top_k=top_k
)
text_out = decode(out[0])
return text_out
# 4️⃣ 시연
# 4️⃣ 시연
prompt = "나: 나는 사람이야. 너는 정체가 뭐니?\n너:"
result = generate_text(
prompt,
max_new_tokens=40,
temperature=0.7,
top_k=32,
top_p=0.9,
repetition_penalty=1.1
)
print("📝 Prompt:", prompt)
print("💬 Generated:\n", result)
📝 Prompt: 나: 나는 사람이야. 너는 정체가 뭐니?
너:
💬 Generated:
나: 나는 사람이야. 너는 정체가 뭐니?
너:
이런 말� 들은 일은 없다. 그들이 원하는 일, 즉 그렇게 당신의 삶에 대한 질문이 있었어요
“내 마음은 좋고, 그래서 좋겠