Download custom_code/pfnet_plamo-2-translate.py from model-metadata/custom-code-py-files: direct link, hf CLI and curl.
- Browser
- Download file 519 Bytes
-
https://huggingface.co/datasets/model-metadata/custom-code-py-files/resolve/main/custom_code/pfnet_plamo-2-translate.py
- Command line
-
hf download hf://datasets/model-metadata/custom-code-py-files/custom_code/pfnet_plamo-2-translate.py
-
curl -L -o pfnet_plamo-2-translate.py https://huggingface.co/datasets/model-metadata/custom-code-py-files/resolve/main/custom_code/pfnet_plamo-2-translate.py
519 Bytes
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "transformers", | |
| # "torch", | |
| # ] | |
| # /// | |
| # Use a pipeline as a high-level helper | |
| from transformers import pipeline | |
| pipe = pipeline("text-generation", model="pfnet/plamo-2-translate", trust_remote_code=True) | |
| messages = [ | |
| {"role": "user", "content": "Who are you?"}, | |
| ] | |
| pipe(messages) | |
| # Load model directly | |
| from transformers import AutoModelForCausalLM | |
| model = AutoModelForCausalLM.from_pretrained("pfnet/plamo-2-translate", trust_remote_code=True) | |