pksx01/alpaca_bhojpuri_instruction
Viewer • Updated • 51.8k • 26 • 1
How to use pksx01/sarvam-1-it-bhojpuri with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="pksx01/sarvam-1-it-bhojpuri")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("pksx01/sarvam-1-it-bhojpuri")
model = AutoModelForCausalLM.from_pretrained("pksx01/sarvam-1-it-bhojpuri", device_map="auto")
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 pksx01/sarvam-1-it-bhojpuri with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "pksx01/sarvam-1-it-bhojpuri"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pksx01/sarvam-1-it-bhojpuri",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/pksx01/sarvam-1-it-bhojpuri
How to use pksx01/sarvam-1-it-bhojpuri with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "pksx01/sarvam-1-it-bhojpuri" \
--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": "pksx01/sarvam-1-it-bhojpuri",
"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 "pksx01/sarvam-1-it-bhojpuri" \
--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": "pksx01/sarvam-1-it-bhojpuri",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use pksx01/sarvam-1-it-bhojpuri with Docker Model Runner:
docker model run hf.co/pksx01/sarvam-1-it-bhojpuri
This model has been instruction tuned from sarvamai/sarvam-1. This is an early checkpoint trained for one complete epoch. Checkpoints with further training will be released in future.
This model can be used to chat in Bhojpuri language.
Use the code below to get started with the model.
import torch
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained("pksx01/sarvam-1-it-bhojpuri")
# Load base model
model = AutoModelForCausalLM.from_pretrained(
"sarvamai/sarvam-1",
torch_dtype=torch.bfloat16,
device_map="auto"
)
model.resize_token_embeddings(len(tokenizer))
# Load the PEFT model
peft_model = PeftModel.from_pretrained(
model,
"pksx01/sarvam-1-it-bhojpuri",
is_trainable=False
)
message = [{"role": "user", "content": "भारत के पहिला प्रधानमंत्री के रहे?"}]
model_ip = tokenizer.apply_chat_template(message, tokenize=False)
tokenized_ip = tokenizer(model_ip, return_tensors="pt").to("cuda")
peft_model.eval()
with torch.no_grad():
op_tokens = peft_model.generate(
**tokenized_ip,
max_new_tokens=250,
temperature=0.01,
top_k=50,
top_p=0.95,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
op = tokenizer.decode(op_tokens[0], skip_special_tokens=True)
print(op)
This model has be trained on an instruction dataset - pksx01/alpaca_bhojpuri_instruction.
Base model
sarvamai/sarvam-1