Instructions to use Writer/palmyra-20b-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Writer/palmyra-20b-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Writer/palmyra-20b-chat")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Writer/palmyra-20b-chat") model = AutoModelForCausalLM.from_pretrained("Writer/palmyra-20b-chat", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Writer/palmyra-20b-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Writer/palmyra-20b-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Writer/palmyra-20b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Writer/palmyra-20b-chat
- SGLang
How to use Writer/palmyra-20b-chat 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 "Writer/palmyra-20b-chat" \ --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": "Writer/palmyra-20b-chat", "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 "Writer/palmyra-20b-chat" \ --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": "Writer/palmyra-20b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Writer/palmyra-20b-chat with Docker Model Runner:
docker model run hf.co/Writer/palmyra-20b-chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -13,8 +13,7 @@ language:
|
|
| 13 |
```py
|
| 14 |
|
| 15 |
import torch
|
| 16 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 17 |
-
from transformers import TextStreamer
|
| 18 |
|
| 19 |
model_name = "Writer/palmyra-20b-chat"
|
| 20 |
|
|
@@ -52,6 +51,9 @@ if "token_type_ids" in model_inputs:
|
|
| 52 |
del model_inputs["token_type_ids"]
|
| 53 |
|
| 54 |
all_inputs = {**model_inputs, **gen_conf}
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
```
|
|
|
|
| 13 |
```py
|
| 14 |
|
| 15 |
import torch
|
| 16 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
|
|
|
| 17 |
|
| 18 |
model_name = "Writer/palmyra-20b-chat"
|
| 19 |
|
|
|
|
| 51 |
del model_inputs["token_type_ids"]
|
| 52 |
|
| 53 |
all_inputs = {**model_inputs, **gen_conf}
|
| 54 |
+
output = model.generate(**all_inputs, streamer=streamer)
|
| 55 |
+
|
| 56 |
+
print("-"*20)
|
| 57 |
+
print(output)
|
| 58 |
|
| 59 |
```
|