Instructions to use pfnet/plamo-13b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pfnet/plamo-13b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pfnet/plamo-13b", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("pfnet/plamo-13b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pfnet/plamo-13b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pfnet/plamo-13b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pfnet/plamo-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pfnet/plamo-13b
- SGLang
How to use pfnet/plamo-13b 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 "pfnet/plamo-13b" \ --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": "pfnet/plamo-13b", "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 "pfnet/plamo-13b" \ --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": "pfnet/plamo-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use pfnet/plamo-13b with Docker Model Runner:
docker model run hf.co/pfnet/plamo-13b
Option: Using GPU with quantized model
I ran the code. But, the code ran on lower speed because the code ran on CPU .
import transformers
pipeline = transformers.pipeline("text-generation", model="pfnet/plamo-13b", trust_remote_code=True)
prompt = """
PLaMo-13B is a LLaMA-based 13B model pre-trained on English and Japanese open datasets, developed by Preferred Networks, Inc. PLaMo-13B is released under Apache v2.0 license.
I translate the above mentioned sentences to Japanese:
"""
print(pipeline(text_inputs=prompt, max_new_tokens=512))
So, I recommend the code instead of the above mentioned code.
pipeline = transformers.pipeline("text-generation", model="pfnet/plamo-13b", device_map="auto",model_kwargs={"load_in_8bit": True},trust_remote_code=True)
The code needs pip install accelerate bitsandbytes scipy but the code runs on higher speed on GPU.
In addition, I ran the code.
import transformers
pipeline = transformers.pipeline("text-generation", model="pfnet/plamo-13b", device_map="auto",model_kwargs={"load_in_8bit": True},trust_remote_code=True)
prompt = """次の英文は私が和訳する予定の文章です。
'PLaMo-13B is a LLaMA-based 13B model pre-trained on English and Japanese open datasets, developed by Preferred Networks, Inc. PLaMo-13B is released under Apache v2.0 license.'
私は以上の英文を次のような日本語に翻訳します。"""
print(pipeline(text_inputs=prompt, max_new_tokens=128))
Then, I got the result.
Loading checkpoint shards: 100%|██████████| 3/3 [00:06<00:00, 2.16s/it]
[{'generated_text': "次の英文は私が和訳する予定の文章です。\n'PLaMo-13B is a LLaMA-based 13B model pre-trained on English and Japanese open datasets, developed by Preferred Networks, Inc. PLaMo-13B is released under Apache v2.0 license.' \n私は以上の英文を次のような日本語に翻訳します。\n「PLaMo-13Bは、英語と日本語のオープンデータセットで訓練された、13Bモデルです。PLaMo-13BはApache v2.0ライセンスの下で公開されています。」\nこの英文を和訳するにあたって、以下の点に注意しました。\n1. 「13B」は「13ビット」の略です。\n2. 「13B」は「13ビット」の略です。\n3. 「13B」は「13ビット」の略です。\n4. 「13B」は"}]
Thank you for your suggestion!
You're right, using such options could speed up the model's inference. However, this requires additional libraries and GPU. Meanwhile, we've confirmed our example can run without GPU.
There are indeed many other options to try, such as torch_dtype="auto" to reduce memory usage. However, adding too many options could potentially confuse users. Therefore, we've decided to stick with the simplest setup in our example.
Thanks again for your input! It helps us continue to improve our examples.
Hey! In order to put the pipeline on device you should use:
pipeline = transformers.pipeline("text-generation", model="pfnet/plamo-13b", trust_remote_code=True, device = "cuda")
Thanks for your comment! While device="cuda" allows the model to run on NVIDIA GPUs, it's not suitable for other hardware. For instance, device="cuda" isn't compatible with MacBooks. Our goal is to make this example as straightforward as possible.
However, we greatly appreciate your valuable suggestions!