Transformers
Safetensors
t5
text2text-generation
protein-language-model
fastplms
custom_code
text-generation-inference
Instructions to use Synthyra/ANKH_base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/ANKH_base with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Synthyra/ANKH_base", trust_remote_code=True) model = AutoModelForSeq2SeqLM.from_pretrained("Synthyra/ANKH_base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Give this artifact's bridge its own config and model subclasses (FastPLMs#50)
Browse filesArtifacts share one FastPLMs runtime per process. Re-exported shared classes let one artifact's model class answer for another with the same config class, for example ESMFold2-300 built as ESMFold2Model after ESMFold2-Fast loaded. Only modeling_fastplms.py changes; the runtime bundle and weights are untouched. https://github.com/Synthyra/FastPLMs/issues/50
- modeling_fastplms.py +29 -13
modeling_fastplms.py
CHANGED
|
@@ -180,16 +180,32 @@ def _install_runtime():
|
|
| 180 |
return package
|
| 181 |
|
| 182 |
_install_runtime()
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
return package
|
| 181 |
|
| 182 |
_install_runtime()
|
| 183 |
+
|
| 184 |
+
def _artifact_class(base, config_class=None):
|
| 185 |
+
"""Subclass a shared runtime class so this artifact registers its own classes.
|
| 186 |
+
|
| 187 |
+
The base constructor is kept explicitly because Transformers turns every config
|
| 188 |
+
subclass into a dataclass, which would otherwise generate a new constructor.
|
| 189 |
+
"""
|
| 190 |
+
namespace = {
|
| 191 |
+
"__module__": __name__,
|
| 192 |
+
"__qualname__": base.__name__,
|
| 193 |
+
"__doc__": base.__doc__,
|
| 194 |
+
"__init__": base.__init__,
|
| 195 |
+
}
|
| 196 |
+
base_config_class = getattr(base, "config_class", None)
|
| 197 |
+
if (
|
| 198 |
+
config_class is not None
|
| 199 |
+
and isinstance(base_config_class, type)
|
| 200 |
+
and issubclass(config_class, base_config_class)
|
| 201 |
+
):
|
| 202 |
+
namespace["config_class"] = config_class
|
| 203 |
+
return type(base.__name__, (base,), namespace)
|
| 204 |
+
|
| 205 |
+
_module_204 = _import_without_bytecode("fastplms.models.ankh.modeling_ankh")
|
| 206 |
+
FastAnkhConfig = _artifact_class(_module_204.FastAnkhConfig)
|
| 207 |
+
FastAnkhForConditionalGeneration = _artifact_class(_module_204.FastAnkhForConditionalGeneration, config_class=FastAnkhConfig)
|
| 208 |
+
FastAnkhForMaskedLMExtension = _artifact_class(_module_204.FastAnkhForMaskedLMExtension, config_class=FastAnkhConfig)
|
| 209 |
+
FastAnkhForSequenceClassification = _artifact_class(_module_204.FastAnkhForSequenceClassification, config_class=FastAnkhConfig)
|
| 210 |
+
FastAnkhForTokenClassification = _artifact_class(_module_204.FastAnkhForTokenClassification, config_class=FastAnkhConfig)
|
| 211 |
+
FastAnkhModel = _artifact_class(_module_204.FastAnkhModel, config_class=FastAnkhConfig)
|