Instructions to use Synthyra/Profluent-E1-300M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/Profluent-E1-300M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="Synthyra/Profluent-E1-300M", trust_remote_code=True)# Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("Synthyra/Profluent-E1-300M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
| """Explicit, reversible Torch runtime configuration. | |
| Importing FastPLMs does not change global Torch settings. Callers that want a | |
| runtime profile opt in with :func:`runtime_profile` and receive their previous | |
| settings back when the context exits. | |
| """ | |
| from __future__ import annotations | |
| from contextlib import contextmanager | |
| from dataclasses import dataclass | |
| from typing import TYPE_CHECKING, Literal | |
| if TYPE_CHECKING: | |
| from collections.abc import Iterator | |
| MatmulPrecision = Literal["highest", "high", "medium"] | |
| class RuntimeProfile: | |
| """Requested Torch settings for a bounded inference or training block.""" | |
| float32_matmul_precision: MatmulPrecision = "highest" | |
| allow_tf32: bool | None = None | |
| def runtime_profile(profile: RuntimeProfile | None = None) -> Iterator[None]: | |
| """Apply a Torch runtime profile and restore the previous global settings. | |
| The default profile requests the highest float32 matrix-multiplication | |
| precision and leaves TF32 policy unchanged. Torch is imported only when the | |
| context is entered. | |
| """ | |
| import torch | |
| selected = profile or RuntimeProfile() | |
| previous_matmul_precision = torch.get_float32_matmul_precision() | |
| matmul_backend = getattr(getattr(torch.backends, "cuda", None), "matmul", None) | |
| cudnn_backend = getattr(torch.backends, "cudnn", None) | |
| previous_matmul_tf32 = ( | |
| getattr(matmul_backend, "allow_tf32", None) if matmul_backend is not None else None | |
| ) | |
| previous_cudnn_tf32 = ( | |
| getattr(cudnn_backend, "allow_tf32", None) if cudnn_backend is not None else None | |
| ) | |
| torch.set_float32_matmul_precision(selected.float32_matmul_precision) | |
| if selected.allow_tf32 is not None: | |
| if matmul_backend is not None and hasattr(matmul_backend, "allow_tf32"): | |
| matmul_backend.allow_tf32 = selected.allow_tf32 | |
| if cudnn_backend is not None and hasattr(cudnn_backend, "allow_tf32"): | |
| cudnn_backend.allow_tf32 = selected.allow_tf32 | |
| try: | |
| yield | |
| finally: | |
| torch.set_float32_matmul_precision(previous_matmul_precision) | |
| if selected.allow_tf32 is not None: | |
| if matmul_backend is not None and previous_matmul_tf32 is not None: | |
| matmul_backend.allow_tf32 = previous_matmul_tf32 | |
| if cudnn_backend is not None and previous_cudnn_tf32 is not None: | |
| cudnn_backend.allow_tf32 = previous_cudnn_tf32 | |
| __all__ = ["MatmulPrecision", "RuntimeProfile", "runtime_profile"] | |