Text Generation
Transformers
PyTorch
Italian
mpt
ipt
alibi
text-generation-inference
text generation
custom_code
Instructions to use efederici/ipt-350m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use efederici/ipt-350m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="efederici/ipt-350m", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("efederici/ipt-350m", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("efederici/ipt-350m", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use efederici/ipt-350m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "efederici/ipt-350m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "efederici/ipt-350m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/efederici/ipt-350m
- SGLang
How to use efederici/ipt-350m 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 "efederici/ipt-350m" \ --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": "efederici/ipt-350m", "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 "efederici/ipt-350m" \ --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": "efederici/ipt-350m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use efederici/ipt-350m with Docker Model Runner:
docker model run hf.co/efederici/ipt-350m
Update adapt_tokenizer.py
Browse files- adapt_tokenizer.py +4 -5
adapt_tokenizer.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
-
from typing import
|
| 2 |
-
from transformers import AutoTokenizer,
|
| 3 |
-
Tokenizer = Union[PreTrainedTokenizer, PreTrainedTokenizerFast]
|
| 4 |
NUM_SENTINEL_TOKENS: int = 100
|
| 5 |
|
| 6 |
-
def adapt_tokenizer_for_denoising(tokenizer:
|
| 7 |
"""Adds sentinel tokens and padding token (if missing).
|
| 8 |
|
| 9 |
Expands the tokenizer vocabulary to include sentinel tokens
|
|
@@ -34,7 +33,7 @@ class AutoTokenizerForMOD(AutoTokenizer):
|
|
| 34 |
"""
|
| 35 |
|
| 36 |
@classmethod
|
| 37 |
-
def from_pretrained(cls, *args, **kwargs):
|
| 38 |
"""See `AutoTokenizer.from_pretrained` docstring."""
|
| 39 |
tokenizer = super().from_pretrained(*args, **kwargs)
|
| 40 |
adapt_tokenizer_for_denoising(tokenizer)
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
from transformers import AutoTokenizer, PreTrainedTokenizerBase
|
|
|
|
| 3 |
NUM_SENTINEL_TOKENS: int = 100
|
| 4 |
|
| 5 |
+
def adapt_tokenizer_for_denoising(tokenizer: PreTrainedTokenizerBase) -> None:
|
| 6 |
"""Adds sentinel tokens and padding token (if missing).
|
| 7 |
|
| 8 |
Expands the tokenizer vocabulary to include sentinel tokens
|
|
|
|
| 33 |
"""
|
| 34 |
|
| 35 |
@classmethod
|
| 36 |
+
def from_pretrained(cls, *args: Any, **kwargs: Any) -> PreTrainedTokenizerBase:
|
| 37 |
"""See `AutoTokenizer.from_pretrained` docstring."""
|
| 38 |
tokenizer = super().from_pretrained(*args, **kwargs)
|
| 39 |
adapt_tokenizer_for_denoising(tokenizer)
|