> ## Documentation Index
> Fetch the complete documentation index at: https://proto.evodesign.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AbLang Antibody Language Model

> AbLang antibody masked language model for local antibody sequence mutation/refinement

![AbLang Antibody Language Model](https://proto-bio.github.io/proto-assets/images/generator/ablang/hero.png)

> [!NOTE]
>
> **License:** AbLang is open source and free for academic and commercial use under a BSD-3-Clause license. Please refer to [the license](https://github.com/oxpig/AbLang2/blob/main/LICENSE) for full terms.

This generator is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.

***

&#x20;Tools Used Tools Used  Source Source  Cite Cite

![](https://proto-bio.github.io/proto-assets/images/tool/ablang/social.png)

&#x20;Go to Tool Page

[Open](https://proto.evodesign.org/docs/tools/masked-models/ablang.md)

![Proto](https://mintcdn.com/bio-pro/cMLt8hAqaP9M3LKy/assets/logo/logo-light.svg?fit=max\&auto=format\&n=cMLt8hAqaP9M3LKy\&q=85\&s=f5e5dfd1b8f9b9db3a0be0e2eb01f678)

evo-design/proto-language

&#x20;View source

[Open](https://github.com/evo-design/proto-language/blob/1a97e675c7e5e4ae0e92be91b1bb7b49f1331104/proto_language/generator/ablang_generator.py#L127)

@articleolsen2022ablang\@articleolsen2024ablang2

```bibtex theme={null}
@article{olsen2022ablang,
  title={AbLang: an antibody language model for completing antibody sequences},
  author={Olsen, Tobias H and Moal, Iain H and Deane, Charlotte M},
  journal={Bioinformatics Advances},
  volume={2},
  number={1},
  pages={vbac046},
  year={2022},
  publisher={Oxford University Press},
  doi={10.1093/bioadv/vbac046}
}

@article{olsen2024ablang2,
  title={Addressing the antibody germline bias and its effect on language models for improved antibody design},
  author={Olsen, Tobias H and Moal, Iain H and Deane, Charlotte M},
  journal={Bioinformatics},
  volume={40},
  number={11},
  pages={btae618},
  year={2024},
  publisher={Oxford University Press},
  doi={10.1093/bioinformatics/btae618}
}
```

&#x20;Copy citation

Generator contributors[![](https://avatars.githubusercontent.com/u/61667248?v=4\&s=64)adititm](https://github.com/adititm)[![](https://avatars.githubusercontent.com/u/21143637?v=4\&s=64)bviggiano](https://github.com/bviggiano)
Antibody sequence mutation generator using the AbLang masked language model.

Masks positions of every proposal with the masking strategy and refills them from
AbLang. The generator applies the mask itself, because `ablang-sample` takes
pre-masked sequences (`_` at positions to restore) rather than a strategy; it uses one
seed per call for both the mask and the tool, as ESM2's sampling tool does internally.

## API Reference

ConfigAbLangGeneratorConfig[ Source](https://github.com/evo-design/proto-language/blob/1a97e675c7e5e4ae0e92be91b1bb7b49f1331104/proto_language/generator/ablang_generator.py#L33)

Configuration object for AbLangGenerator.

Sampling defaults follow `AbLangSampleConfig` in proto-tools
(`proto_tools/tools/masked_models/ablang/ablang_sample.py`). AbLang picks its
checkpoint from the chains it receives: heavy-only input runs `ablang1-heavy` and
paired input runs `ablang2-paired`.

**masking\_strategy** `RandomMaskingStrategy`

Which positions to resample (random selection). Default: random 30%.

**temperature** `number` (default: 1.0)

Sampling temperature for refilled residues; 0 is greedy argmax.

**heavy\_slice** `array`

VH region (start, end) within the segment; set with light\_slice for paired sampling.

**light\_slice** `array`

VL region (start, end) within the segment; set with heavy\_slice for paired sampling.

**excluded\_amino\_acids** `array`

Single-letter codes never sampled at masked positions (e.g. \['C'] to forbid cysteine).

**device** `string` (default: cuda)

GPU device to run AbLang on (e.g. 'cuda' or 'cuda:0').

**batch\_size** `integer` (default: 1)

Number of sequences to process simultaneously on GPU

## Usage

```python python icon="python" theme={null}
>>> from proto_language.core import Segment
>>> from proto_language.generator import AbLangGenerator, AbLangGeneratorConfig
>>> from proto_tools.transforms.masking import RandomMaskingStrategy
>>> heavy = (  # 1JPT heavy chain
...     "EVQLVESGGGLVQPGGSLRLSCAASGFNIKEYYMHWVRQAPGKGLEWVGLIDPEQGNTIYDPKFQDRATIS"
...     "ADNSKNTAYLQMNSLRAEDTAVYYCARDTAAYFDYWGQGTLVTVS"
... )
>>> gen = AbLangGenerator(AbLangGeneratorConfig(masking_strategy=RandomMaskingStrategy(num_mutations=5)))
>>> gen.assign(Segment(sequence=heavy, sequence_type="protein"))
>>> gen.sample()  # 5 random positions refilled by AbLang's heavy-chain model
```

## Metadata

| Property | Value |
| - | - |
| Key | `ablang` |
| Class | `AbLangGenerator` |
| Category | `mutation` |
| Input Type | `starting_sequence` |
| Uses GPU | `True` |
| Supported Sequence Types | `protein` |
| Allows Empty Start | `False` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.