Vikhrmodels/GrandMaster-PRO-MAX
Viewer • Updated • 155k • 751 • 77
How to use belyakoff/SmolLM2-360M-Instruct-FT with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="belyakoff/SmolLM2-360M-Instruct-FT")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("belyakoff/SmolLM2-360M-Instruct-FT")
model = AutoModelForCausalLM.from_pretrained("belyakoff/SmolLM2-360M-Instruct-FT")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use belyakoff/SmolLM2-360M-Instruct-FT with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "belyakoff/SmolLM2-360M-Instruct-FT"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "belyakoff/SmolLM2-360M-Instruct-FT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/belyakoff/SmolLM2-360M-Instruct-FT
How to use belyakoff/SmolLM2-360M-Instruct-FT with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "belyakoff/SmolLM2-360M-Instruct-FT" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "belyakoff/SmolLM2-360M-Instruct-FT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "belyakoff/SmolLM2-360M-Instruct-FT" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "belyakoff/SmolLM2-360M-Instruct-FT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use belyakoff/SmolLM2-360M-Instruct-FT with Docker Model Runner:
docker model run hf.co/belyakoff/SmolLM2-360M-Instruct-FT
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("belyakoff/SmolLM2-360M-Instruct-FT")
model = AutoModelForCausalLM.from_pretrained("belyakoff/SmolLM2-360M-Instruct-FT")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))v1: SFT -- 7658aab7702e56d9f5fa3b33bf7adcdae92f536b
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "belyakoff/SmolLM2-360M-Instruct-FT"
device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
messages = [{"role": "user", "content": "Столица России?"}]
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
print(input_text)
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
print(tokenizer.decode(outputs[0]))
# Столица России — Москва. Это один из самых известных и культурно значимых городов в мире.
Don't change system prompt. Changing system prompt will make the model go crazy.
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="belyakoff/SmolLM2-360M-Instruct-FT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)