Views
No views yet
Synthyra/ANKH3_large packages the ElnaggarLab/ankh3-large checkpoint with
the FastPLMs runtime for Hugging Face Transformers. It accepts amino-acid
sequences tokenized for encoder or sequence-to-sequence use.trust_remote_code=True. See Technical details for each registered class and
whether its weights come from the checkpoint.1python -m pip install -r \
2 "https://huggingface.co/Synthyra/ANKH3_large/resolve/main/requirements.txt"trust_remote_code=True.1from transformers import AutoModel
2
3model_id = "Synthyra/ANKH3_large"
4model = AutoModel.from_pretrained(
5 model_id,
6 trust_remote_code=True,
7 attn_implementation="sdpa",
8).eval()model_id with the manifest-built
dist/hub/ANKH3_large path. Pass local_files_only=True.sdpa.eager, sdpa. Requesting an unavailable backend
raises instead of silently changing implementation.output_attentions=True can use the documented one-call eager fallback to
materialize attention tensors. The configured backend does not change.Synthyra/ANKH3_large contains the complete encoder-decoder checkpoint.
AutoModel loads the encoder without the decoder. AutoModelForSeq2SeqLM
loads the encoder, decoder, cross-attention, and language-model head.1import torch
2
3tokenizer = model.tokenizer
4batch = tokenizer(
5 ["MSTNPKPQRKTKRNT", "MKTIIALSYIFCLVFA"],
6 padding=True,
7 return_tensors="pt",
8)
9
10with torch.inference_mode():
11 output = model(**batch)
12
13print(output.last_hidden_state.shape)1encoder_result = model.embed_dataset(
2 ["MSTNPKPQRKTKRNT"],
3 hidden_state_source="encoder",
4 hidden_state_index=-1,
5 full_embeddings=True,
6)
7print(encoder_result[0].tensor.shape) # (l, d)AutoModelForSeq2SeqLM and one aligned decoder
input. ANKH does not create a shifted target:1from transformers import AutoModelForSeq2SeqLM
2
3seq2seq = AutoModelForSeq2SeqLM.from_pretrained(
4 "Synthyra/ANKH3_large",
5 trust_remote_code=True,
6).eval()
7decoder_result = seq2seq.embed_dataset(
8 ["MSTNPKPQRKTKRNT"],
9 hidden_state_source="decoder",
10 hidden_state_index=-1,
11 decoder_inputs=["M<extra_id_0>"],
12 full_embeddings=True,
13)
14print(decoder_result[0].tensor.shape) # (decoder_length, d)classifier. Sequence labels have shape (b,).
Residue labels have shape (b, l) and use -100 outside biological positions.1import torch
2from transformers import AutoTokenizer
3from transformers import (
4 AutoModelForSequenceClassification,
5 AutoModelForTokenClassification,
6)
7
8model_id = "Synthyra/ANKH3_large"
9sequence_model = AutoModelForSequenceClassification.from_pretrained(
10 model_id, num_labels=2, trust_remote_code=True
11).eval()
12token_model = AutoModelForTokenClassification.from_pretrained(
13 model_id, num_labels=3, trust_remote_code=True
14).eval()
15tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
16sequences = ["MSTNPKPQRKTKRNT", "MKTIIALSYIFCLVFA"]
17batch = tokenizer(sequences, padding=True, return_tensors="pt")
18biological = batch["attention_mask"].bool()
19for special_id in tokenizer.all_special_ids:
20 biological &= batch["input_ids"].ne(special_id)
21
22sequence_labels = torch.zeros(len(sequences), dtype=torch.long)
23token_labels = torch.full_like(batch["input_ids"], -100)
24token_labels[biological] = 0
25
26with torch.inference_mode():
27 sequence_output = sequence_model(**batch, labels=sequence_labels)
28 token_output = token_model(**batch, labels=token_labels)
29print(sequence_output.logits.shape) # (b, 2)
30print(token_output.logits.shape) # (b, l, 3)python -m pip install "datasets>=4.8,<5" "peft>=0.19,<0.20"1from peft import LoraConfig, TaskType, get_peft_model
2
3peft_model = get_peft_model(
4 sequence_model,
5 LoraConfig(
6 task_type=TaskType.SEQ_CLS,
7 r=8,
8 lora_alpha=16,
9 target_modules="all-linear",
10 modules_to_save=["classifier"],
11 ),
12)classifier with the adapter.
All FastPLMs checkpoints follow the Transformers PreTrainedModel contract and
can use PEFT. The ESM2-specific shipped CLI is an example, not a
support boundary. Record the target modules, base revision, data identity, and
trainable parameter scope.1from transformers import AutoModelForMaskedLM
2
3ttt_model = AutoModelForMaskedLM.from_pretrained(
4 "Synthyra/ANKH3_large",
5 trust_remote_code=True,
6)
7metrics = ttt_model.ttt(
8 seq="MSTNPKPQRKTKRNT",
9 ttt_config={"steps": 3, "batch_size": 1, "seed": 7},
10)
11ttt_model.save_pretrained("adapted", safe_serialization=True)
12ttt_model.ttt_reset()
13print(metrics)Synthyra/ANKH3_large contains the complete ANKH encoder-decoder checkpoint.
Use AutoModel for encoder embeddings. Use AutoModelForSeq2SeqLM for
task-specific decoding:1import torch
2from transformers import AutoModel, AutoModelForSeq2SeqLM, AutoTokenizer
3
4repo_id = "Synthyra/ANKH3_large"
5tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
6encoder = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()
7seq2seq = AutoModelForSeq2SeqLM.from_pretrained(
8 repo_id,
9 trust_remote_code=True,
10).eval()
11batch = tokenizer("MSTNPKPQRKTKRNT", return_tensors="pt")
12
13with torch.inference_mode():
14 encoder_hidden = encoder(**batch).last_hidden_state
15 generated_ids = seq2seq.generate(**batch, max_new_tokens=16)
16print(encoder_hidden.shape)
17print(tokenizer.batch_decode(generated_ids, skip_special_tokens=True))AutoConfig, AutoModel, AutoModelForMaskedLM, AutoModelForSeq2SeqLM, AutoModelForSequenceClassification, AutoModelForTokenClassificationAutoConfig = FastPLMs extension, AutoModel = pretrained, AutoModelForMaskedLM = FastPLMs extension, AutoModelForSeq2SeqLM = pretrained, AutoModelForSequenceClassification = base weights + untrained task head, AutoModelForTokenClassification = base weights + untrained task headeager, sdpadefaultstatic_parametersrequiredcoretrueresolvedtruefalsemodels.toml. Built artifacts record exact source
identities and conversion details in source-record.json.Synthyra/ANKH3_largesource-record.jsonsource-record.jsonsource-record.jsonElnaggarLab/ankh3-largeofficialankh_t5_to_fastplms_v1ankhcheck, compliance, feature, artifact, benchmark0compliance tier. Its evidence identifies the
checkpoint, backend, dtype, hardware, inputs, and reference revision.cc-by-nc-sa-4.0. The local artifact contains applicable source
licenses, notices, attribution, and conversion records. Review them before use.