roneneldan/TinyStories
Viewer • Updated • 2.14M • 87.1k • 1.02k
How to use idah4/byteetm-korean-tiny with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="idah4/byteetm-korean-tiny", trust_remote_code=True) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("idah4/byteetm-korean-tiny", trust_remote_code=True, dtype="auto")How to use idah4/byteetm-korean-tiny with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "idah4/byteetm-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/byteetm-korean-tiny",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/idah4/byteetm-korean-tiny
How to use idah4/byteetm-korean-tiny with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "idah4/byteetm-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/byteetm-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/byteetm-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/byteetm-korean-tiny",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use idah4/byteetm-korean-tiny with Docker Model Runner:
docker model run hf.co/idah4/byteetm-korean-tiny
소형 바이트-레벨 텍스트 디코더 LM
# %% ByteETM Inference (바이트 기반 추론)
import torch
from transformers import AutoModelForCausalLM
# 1️⃣ 모델 로드
repo_id = "idah4/byteetm-korean-tiny"
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForCausalLM.from_pretrained(
repo_id,
trust_remote_code=True
).to(device).eval()
# 2️⃣ 바이트 기반 인코더 / 디코더
def encode_bytes(text: str):
return torch.tensor([[b for b in text.encode("utf-8")]], dtype=torch.long, device=device)
def decode_bytes(ids: torch.Tensor):
seq = [i for i in ids.tolist() if 0 <= i < 256]
return bytes(seq).decode("utf-8", errors="ignore")
# 3️⃣ 텍스트 생성 함수
@torch.no_grad()
def generate_text(prompt: str, max_new_tokens=200, temperature=0.8, top_k=200):
input_ids = encode_bytes(prompt)
out = model.generate(
input_ids,
max_new_tokens=max_new_tokens,
temperature=temperature,
top_k=top_k
)
return decode_bytes(out[0])
# 4️⃣ 시연
prompt = "오늘은 날씨가 좋아서"
print(generate_text(prompt, max_new_tokens=150, temperature=0.9, top_k=150))