KolhapurLLM
Collection
2 items • Updated
How to use pmking27/PrathameshLLM-2B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="pmking27/PrathameshLLM-2B") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("pmking27/PrathameshLLM-2B")
model = AutoModelForCausalLM.from_pretrained("pmking27/PrathameshLLM-2B")How to use pmking27/PrathameshLLM-2B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "pmking27/PrathameshLLM-2B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pmking27/PrathameshLLM-2B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/pmking27/PrathameshLLM-2B
How to use pmking27/PrathameshLLM-2B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "pmking27/PrathameshLLM-2B" \
--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": "pmking27/PrathameshLLM-2B",
"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 "pmking27/PrathameshLLM-2B" \
--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": "pmking27/PrathameshLLM-2B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use pmking27/PrathameshLLM-2B with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pmking27/PrathameshLLM-2B to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pmking27/PrathameshLLM-2B to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for pmking27/PrathameshLLM-2B to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="pmking27/PrathameshLLM-2B",
max_seq_length=2048,
)How to use pmking27/PrathameshLLM-2B with Docker Model Runner:
docker model run hf.co/pmking27/PrathameshLLM-2B
This gemma model was trained 2x faster with Unsloth and Huggingface's TRL library.
# Importing necessary modules
from transformers import AutoModelForCausalLM, AutoTokenizer
# Setting the device to load the model onto (assuming GPU availability)
device = 'cuda'
# Loading the tokenizer for the model
tokenizer = AutoTokenizer.from_pretrained("pmking27/PrathameshLLM-2B")
# Loading the pre-trained model
model = AutoModelForCausalLM.from_pretrained("pmking27/PrathameshLLM-2B")
# Defining the Alpaca prompt template
alpaca_prompt = """
### Instruction:
{}
### Input:
{}
### Response:
{}"""
# Providing the input to the model
model_inputs = tokenizer(
[
alpaca_prompt.format(
'''
You're an assistant trained to answer questions using the given context.
context:
General elections will be held in India from 19 April 2024 to 1 June 2024 to elect the 543 members of the 18th Lok Sabha. The elections will be held in seven phases and the results will be announced on 4 June 2024. This will be the largest-ever election in the world, surpassing the 2019 Indian general election, and will be the longest-held general elections in India with a total span of 44 days (excluding the first 1951–52 Indian general election). The incumbent prime minister Narendra Modi who completed a second term will be contesting elections for a third consecutive term.
Approximately 960 million individuals out of a population of 1.4 billion are eligible to participate in the elections, which are expected to span a month for completion. The Legislative assembly elections in the states of Andhra Pradesh, Arunachal Pradesh, Odisha, and Sikkim will be held simultaneously with the general election, along with the by-elections for 35 seats among 16 states.
''', # instruction
"भारतातील सार्वत्रिक निवडणुका किती टप्प्यात पार पडतील?", # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt")
# Moving model inputs to the specified device
model_inputs.to(device)
model.to(device)
# Generating responses from the model
outputs = model.generate(**model_inputs, max_new_tokens=100)
decoded_output = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
# Finding the start and end positions of the response
start_marker = "### Response:"
end_marker = "<eos>"
start_pos = decoded_output.find(start_marker) + len(start_marker)
end_pos = decoded_output.find(end_marker, start_pos)
# Extracting the response text
response_text = decoded_output[start_pos:end_pos].strip()
print(response_text)
भारतातील सार्वत्रिक निवडणुका 7 टप्प्यांमध्ये पार पडतील.