IgorVolochay/russian_jokes
Viewer • Updated • 151k • 170 • 11
How to use 01eg0/llm-course-hw1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="01eg0/llm-course-hw1") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("01eg0/llm-course-hw1", dtype="auto")How to use 01eg0/llm-course-hw1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "01eg0/llm-course-hw1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "01eg0/llm-course-hw1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/01eg0/llm-course-hw1
How to use 01eg0/llm-course-hw1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "01eg0/llm-course-hw1" \
--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": "01eg0/llm-course-hw1",
"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 "01eg0/llm-course-hw1" \
--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": "01eg0/llm-course-hw1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use 01eg0/llm-course-hw1 with Docker Model Runner:
docker model run hf.co/01eg0/llm-course-hw1
Модель - компактный авто-регрессионный Transformer для генерации коротких шуток на русском языке. Обучена на датасете IgorVolochay/russian_jokes.
Выполнена в рамках домашней работы по курсу «Большие языковые модели»
Начало «Шел медведь по лесу»:
Шел медведь по лесу, видит - машина горит. Мимо идет волк.
- Сынок, ты кем работаешь?
Начало «Штирлиц пришел домой»:
Штирлиц пришел домой. Взял медали, сел в сумку и говорит: "Сегодня ночью в тюрьме!"
Начало «Заходит в бар»:
Заходит в барана кошка, без презерватива
import torch
# Нужна инициализация ByteLevelBPETokenizer и TransformerForCausalLM из ipynb ноутбука домашнего задания
REPO_NAME = "01eg0/llm-course-hw1"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = ByteLevelBPETokenizer.from_pretrained(REPO_NAME)
model = TransformerForCausalLM.from_pretrained(REPO_NAME).to(device).eval()
text = "Штирлиц пришел домой"
input_ids = torch.tensor(tokenizer.encode(text), device=device)
model_output = check_model.generate(
input_ids[None, :], max_new_tokens=200, eos_token_id=tokenizer.eos_token_id, do_sample=True, top_k=10
)
tokenizer.decode(model_output[0].tolist())