openchat/openchat_sharegpt4_dataset
Updated • 675 • 173
How to use nnpy/opt-350m-instruct with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="nnpy/opt-350m-instruct") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("nnpy/opt-350m-instruct")
model = AutoModelForCausalLM.from_pretrained("nnpy/opt-350m-instruct")How to use nnpy/opt-350m-instruct with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "nnpy/opt-350m-instruct"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "nnpy/opt-350m-instruct",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/nnpy/opt-350m-instruct
How to use nnpy/opt-350m-instruct with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "nnpy/opt-350m-instruct" \
--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": "nnpy/opt-350m-instruct",
"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 "nnpy/opt-350m-instruct" \
--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": "nnpy/opt-350m-instruct",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use nnpy/opt-350m-instruct with Docker Model Runner:
docker model run hf.co/nnpy/opt-350m-instruct
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained('facebook/opt-350m')
model = AutoModelForCausalLM.from_pretrained('prasanna2003/opt-350m-instruct')
system_message = "You are AI language model helps the human."
input_prompt = "Define data science."
prompt = '<system>' + system_message + '<human>' + input_prompt + '<assistant>'
prompt = tokenizer(prompt, return_tensors='pt')
out = model.generate(**prompt, max_length=120)
print(tok.decode(out[0]))