Instructions to use ibm-research/PowerLM-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-research/PowerLM-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ibm-research/PowerLM-3b")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ibm-research/PowerLM-3b") model = AutoModelForCausalLM.from_pretrained("ibm-research/PowerLM-3b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ibm-research/PowerLM-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-research/PowerLM-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-research/PowerLM-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ibm-research/PowerLM-3b
- SGLang
How to use ibm-research/PowerLM-3b 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 "ibm-research/PowerLM-3b" \ --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": "ibm-research/PowerLM-3b", "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 "ibm-research/PowerLM-3b" \ --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": "ibm-research/PowerLM-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ibm-research/PowerLM-3b with Docker Model Runner:
docker model run hf.co/ibm-research/PowerLM-3b
Update README.md
Browse files
README.md
CHANGED
|
@@ -136,12 +136,9 @@ tokenizer = AutoTokenizer.from_pretrained(model_path)
|
|
| 136 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
|
| 137 |
model.eval()
|
| 138 |
# change input text as desired
|
| 139 |
-
|
| 140 |
-
{ "role": "user", "content": "Write a code to find the maximum value in a list of numbers." },
|
| 141 |
-
]
|
| 142 |
-
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
| 143 |
# tokenize the text
|
| 144 |
-
input_tokens = tokenizer(
|
| 145 |
# transfer tokenized inputs to the device
|
| 146 |
for i in input_tokens:
|
| 147 |
input_tokens[i] = input_tokens[i].to(device)
|
|
|
|
| 136 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
|
| 137 |
model.eval()
|
| 138 |
# change input text as desired
|
| 139 |
+
prompt = "Write a code to find the maximum value in a list of numbers."
|
|
|
|
|
|
|
|
|
|
| 140 |
# tokenize the text
|
| 141 |
+
input_tokens = tokenizer(prompt, return_tensors="pt")
|
| 142 |
# transfer tokenized inputs to the device
|
| 143 |
for i in input_tokens:
|
| 144 |
input_tokens[i] = input_tokens[i].to(device)
|