kyujinpy/Open-platypus-Commercial
Viewer • Updated • 19.1k • 956 • 4
How to use field2437/phi-2-platypus-Commercial-lora with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="field2437/phi-2-platypus-Commercial-lora", trust_remote_code=True) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("field2437/phi-2-platypus-Commercial-lora", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("field2437/phi-2-platypus-Commercial-lora", trust_remote_code=True)How to use field2437/phi-2-platypus-Commercial-lora with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "field2437/phi-2-platypus-Commercial-lora"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "field2437/phi-2-platypus-Commercial-lora",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/field2437/phi-2-platypus-Commercial-lora
How to use field2437/phi-2-platypus-Commercial-lora with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "field2437/phi-2-platypus-Commercial-lora" \
--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": "field2437/phi-2-platypus-Commercial-lora",
"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 "field2437/phi-2-platypus-Commercial-lora" \
--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": "field2437/phi-2-platypus-Commercial-lora",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use field2437/phi-2-platypus-Commercial-lora with Docker Model Runner:
docker model run hf.co/field2437/phi-2-platypus-Commercial-lora
Model Developers
Base Model
Training Dataset
AI-Harness evaluation; link
| Model | Copa | HellaSwag | BoolQ | MMLU |
|---|---|---|---|---|
| 0-shot | 0-shot | 0-shot | 0-shot | |
| phi-2-platypus-Commercial-lora | 0.8900 | 0.5573 | 0.8260 | 0.5513 |
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
torch.set_default_device("cuda")
model = AutoModelForCausalLM.from_pretrained("field2437/phi-2-platypus-Commercial-lora", torch_dtype="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("field2437/phi-2-platypus-Commercial-lora", trust_remote_code=True)
inputs = tokenizer('''Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Let $f(x)$ be the polynomial \\[f(x)=3x^4+5x^2-9x-2.\\] If $g(x)$ is equal to the polynomial $f(x-1)$, what is the sum of the coefficients of $g$?
### Response:
''', return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)