Instructions to use teknium/Puffin-Phi-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use teknium/Puffin-Phi-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="teknium/Puffin-Phi-v2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("teknium/Puffin-Phi-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use teknium/Puffin-Phi-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "teknium/Puffin-Phi-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "teknium/Puffin-Phi-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/teknium/Puffin-Phi-v2
- SGLang
How to use teknium/Puffin-Phi-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "teknium/Puffin-Phi-v2" \ --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": "teknium/Puffin-Phi-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
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 "teknium/Puffin-Phi-v2" \ --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": "teknium/Puffin-Phi-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use teknium/Puffin-Phi-v2 with Docker Model Runner:
docker model run hf.co/teknium/Puffin-Phi-v2
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
lang: eng
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Model Card for Puffin-Phi V2
|
| 6 |
+
|
| 7 |
+
This is my first fine-tune of Puffin that seems to be working fairly reliably!
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
|
| 11 |
+
## Model Details
|
| 12 |
+
|
| 13 |
+
### Model Sources [optional]
|
| 14 |
+
|
| 15 |
+
This model was trained on the Puffin Dataset, made by LDJ, using a slightly modified version of the dataset that removed >2000 token entries, so there would be no early cutoffs during training phi, since it's context is 2k.
|
| 16 |
+
|
| 17 |
+
## Uses
|
| 18 |
+
|
| 19 |
+
Let me know!
|
| 20 |
+
|
| 21 |
+
## How to Get Started with the Model
|
| 22 |
+
|
| 23 |
+
Phi does not support device_map "auto", and does not seem to want to inference in fp16, so use bf16.
|
| 24 |
+
|
| 25 |
+
Here is working code to inference, though it can be improved:
|
| 26 |
+
```
|
| 27 |
+
import torch
|
| 28 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 29 |
+
|
| 30 |
+
sysprompt = "The assistant gives helpful, detailed, and polite answers to the user's questions.\n"
|
| 31 |
+
|
| 32 |
+
model = AutoModelForCausalLM.from_pretrained("teknium/Puffin-Phi-v2", trust_remote_code=True, torch_dtype=torch.bfloat16).to("cuda")
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained("teknium/Puffin-Phi-v2", trust_remote_code=True, torch_dtype=torch.bfloat16)
|
| 34 |
+
inputs = tokenizer(f"{sysprompt}USER: Write a negative review for the website Twitter.\nASSISTANT:", return_tensors="pt", return_attention_mask=False)
|
| 35 |
+
outputs = model.generate(**inputs, max_length=128, do_sample=True, temperature=0.2, top_p=0.9, use_cache=True, repetition_penalty=1.2, eos_token_id=tokenizer.eos_token_id)
|
| 36 |
+
text = tokenizer.batch_decode(outputs)[0]
|
| 37 |
+
print(text)
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
The prompt format is ShareGPT/Vicuna, so it uses the sysprompt (defualt in sysprompt variable)
|
| 41 |
+
then is prompted like so:
|
| 42 |
+
|
| 43 |
+
```
|
| 44 |
+
USER: <prompt>
|
| 45 |
+
ASSISTANT:
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Training Details
|
| 49 |
+
|
| 50 |
+
### Training Procedure
|
| 51 |
+
|
| 52 |
+
Trained with Axolotl. View the wandb runs for all my puffin runs (this is puffin-phi-4 on wandb):
|
| 53 |
+
https://wandb.ai/teknium1/puffin-phi/runs/puffin-phi-4
|
| 54 |
+
|
| 55 |
+
## Evaluation
|
| 56 |
+
|
| 57 |
+
TODO
|
| 58 |
+
|