# Evolla

## 概述

The Evolla model was proposed in [Decoding the Molecular Language of Proteins with Evolla](https://doi.org/10.1101/2025.01.05.630192) by [Zhou et al.](https://doi.org/10.1101/2025.01.05.630192).

Evolla 是一款先进的 800 亿参数蛋白质语言生成模型，旨在解码蛋白质的分子语言。它整合了蛋白质序列、结构以及用户查询中的信息，从而生成关于蛋白质功能的精确且富有语境细微差别的见解。Evolla 在一个前所未有的 AI 生成数据集上进行训练，该数据集包含 5.46 亿个蛋白质问答对和 1500 亿个词元（word tokens）。Evolla 显著推动了蛋白质组学和功能性基因组学的研究，提供了专家级的见解，并揭示了蛋白质中编码的分子逻辑。

该论文的摘要如下：

*蛋白质是自然界精密的分子机器，是数十亿年进化的产物，在维持生命方面发挥着基础性作用。然而，破译其分子语言——即理解蛋白质序列和结构如何编码并决定生物功能——仍然是现代生物学中的基石性挑战。在此，我们介绍了 Evolla，一个 800 亿参数的前沿蛋白质语言生成模型，旨在解码蛋白质的分子语言。通过整合来自蛋白质序列、结构和用户查询的信息，Evolla 能够生成关于蛋白质功能的精确且富有语境细微差别的见解。Evolla 的一项关键创新在于其在一个前所未有的 AI 生成数据集上进行训练：5.46 亿个蛋白质问答对和 1500 亿个词元（word tokens），旨在反映蛋白质巨大的复杂性和功能多样性。在预训练之后，Evolla 集成了直接偏好优化（DPO）以基于偏好信号优化模型，并集成了检索增强生成（RAG）以纳入外部知识，从而提高了响应质量和相关性。为了评估其性能，我们提出了一个新颖的框架，即指令响应空间（IRS），证明 Evolla 能够提供专家级的见解，推动蛋白质组学和功能性基因组学的研究，同时揭示编码在蛋白质中的分子逻辑。在线演示可在 http://www.chat-protein.com/ 获取。*

示例：

```python
processor = EvollaProcessor.from_pretrained("westlake-repl/Evolla-10B-DPO-hf")
model = EvollaForProteinText2Text.from_pretrained("westlake-repl/Evolla-10B-DPO-hf", device_map="auto")
# aa_seq should have same length as foldseek
protein_inputs = [
    {

        "aa_seq": "MATGGRRG...",
        "foldseek": "###lqpfd...", # hashtag means the low-confidence foldseek tokens
    },
    {
        "aa_seq": "MLPGLALL...",
        "foldseek": "dfwwkwad...",
    }
]
message_list = [
    [
        {
            "role": "system",
            "content": "You are an AI expert that can answer any questions about protein.",
        },
        {"role": "user", "content": "What is the function of this protein?"},
    ],
    [
        {
            "role": "system",
            "content": "You are an AI expert that can answer any questions about protein.",
        },
        {"role": "user", "content": "What is the function of this protein?"},
    ]
]
input_dict = processor(
    protein_inputs, messages_list, return_tensors="pt", text_max_length=512, protein_max_length=1024
)
with torch.no_grad():
    generated_ids = hf_model.generate(**input_dict)
generated_texts = processor.batch_decode(
    generated_ids, skip_special_tokens=True
)
```

提示：

- 该模型由 [Xibin Bayes Zhou](https://huggingface.co/XibinBayesZhou) 贡献。
- 原始代码可以在[此处](https://github.com/westlake-repl/Evolla)找到。

## EvollaConfig[[transformers.EvollaConfig]]

#### transformers.EvollaConfig[[transformers.EvollaConfig]]

```python
transformers.EvollaConfig(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, protein_encoder_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, vocab_size: int = 128256, hidden_size: int = 4096, intermediate_size: int = 14336, num_hidden_layers: int = 32, num_attention_heads: int = 32, num_key_value_heads: int | None = 8, hidden_act: str = 'silu', max_position_embeddings: int = 8192, rms_norm_eps: float = 1e-05, rope_parameters: transformers.modeling_rope_utils.RopeParameters | dict | None = None, attention_bias: bool = False, attention_dropout: float | int | None = 0.0, mlp_bias: bool = False, aligner_ffn_mult: int | None = 4, aligner_enable_bias: bool | None = True, aligner_attention_probs_dropout_prob: float | None = 0.1, aligner_num_add_layers: int | None = 8, resampler_depth: int | None = 6, resampler_dim_head: int | None = 64, resampler_heads: int | None = 8, resampler_num_latents: int | None = 64, resampler_ff_mult: int | None = 4, initializer_range: float = 0.02, pad_token_id: int | None = None, bos_token_id: int | None = 128000, eos_token_id: int | list[int] | None = 128009, use_cache: bool = False, tie_word_embeddings: bool = False, is_decoder: bool | None = False, add_cross_attention: bool | None = False)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/configuration_evolla.py#L64)

**参数：**

protein_encoder_config (`dict`, *可选*) : 用于初始化 `SaProtConfig` 的配置选项字典。

vocab_size (`int`，*可选*，默认值为 `128256`)：模型的词汇表大小。定义了 `input_ids` 可以表示的不同 token 数量。

hidden_size (`int`，*可选*，默认为 `4096`)：隐藏表示的维度。

intermediate_size (`int`，*可选*，默认值为 `14336`)：MLP 表示的维度。

num_hidden_layers (`int`，*可选*，默认为 `32`)：Transformer 解码器中的隐藏层数。

num_attention_heads (`int`，*可选*，默认为 `32`)：Transformer 解码器中每个注意力层的注意力头数量。

num_key_value_heads (`int`, *可选*，默认为 `8`) : 这是用于实现 Grouped Query Attention 的 key_value 头数量。如果 `num_key_value_heads=num_attention_heads`，模型将使用 Multi Head Attention (MHA)；如果 `num_key_value_heads=1`，模型将使用 Multi Query Attention (MQA)；否则将使用 GQA。在将多头检查点转换为 GQA 检查点时，每个组的 key 和 value 头应通过对该组内所有原始头进行平均池化来构建。更多详情请参阅 [这篇论文](https://huggingface.co/papers/2305.13245)。如果未指定，则默认为 `num_attention_heads`。

hidden_act (`str`，*可选*，默认为 `silu`)：解码器中的非线性激活函数（函数或字符串）。例如，`"gelu"`、`"relu"`、`"silu"` 等。

max_position_embeddings (`int`，*可选*，默认为 `8192`)：该模型可能使用的最大序列长度。

rms_norm_eps (`float`，*可选*，默认值为 `1e-05`)：rms 归一化层中使用的 epsilon。

rope_parameters (`Union[~modeling_rope_utils.RopeParameters, dict]`, *可选*) : 包含 RoPE 嵌入配置参数的字典。该字典应包含 `rope_theta` 的值，并且如果希望使用更长的 `max_position_embeddings` 配合 RoPE，则可选地包含用于缩放的参数。

attention_bias (`bool`，*可选*，默认为 `False`)：在自注意力机制中，是否在查询、键、值和输出投影层中使用偏置。

attention_dropout (`Union[float, int]`，*可选*，默认值为 `0.0`)：注意力概率的 dropout 比率。

mlp_bias (`bool`，*可选*，默认为 `False`)：是否在 MLP 层的 up_proj、down_proj 和 gate_proj 层中使用偏置。

aligner_ffn_mult (`int`，*可选*，默认为 4)：对齐层（aligner layer）的 FFN 乘数。

aligner_enable_bias (`bool`, *可选*, 默认为 `True`) : 是否在 aligner 层中使用偏置。

aligner_attention_probs_dropout_prob (`float`, *可选*，默认为 0.1)：对齐层中注意力概率的 dropout 比率。

aligner_num_add_layers (`int`，*可选*，默认为 8)：对齐器层的额外层数。

resampler_depth (`int`, *可选*, 默认为 6) : llama 模型中重采样层的深度。

resampler_dim_head (`int`, *可选*，默认为 64)：llama 模型中重采样层中头的维度。

resampler_heads (`int`，*可选*，默认为 8)：llama 模型中重采样器层的头数。

resampler_num_latents (`int`，*可选*，默认为 64)：llama 模型中重采样器层中潜在向量的数量。

resampler_ff_mult (`int`，*可选*，默认为 4)：重采样器层的 FFN 乘数。

initializer_range (`float`，*可选*，默认值为 `0.02`)：用于初始化所有权重矩阵的 truncated_normal_initializer 的标准差。

pad_token_id (`int`, *可选*) : 词表中用于填充的 Token id。

bos_token_id (`int`，*可选*，默认值为 `128000`)：词表中用于表示流起始的 Token ID。

eos_token_id (`Union[int, list[int]]`，*可选*，默认为 `128009`)：词汇表中用于表示流结束（end-of-stream）的 Token ID。

use_cache (`bool`，*可选*，默认为 `False`)：模型是否应返回最后的键/值注意力（并非所有模型都使用）。仅当 `config.is_decoder=True` 或模型为仅解码器生成模型时相关。

tie_word_embeddings (`bool`，*可选*，默认为 `False`)：是否根据模型的 `tied_weights_keys` 映射来绑定权重嵌入。

is_decoder (`bool`，*可选*，默认为 `False`)：模型是否用作解码器。如果为 `False`，则模型用作编码器。

add_cross_attention (`bool`，*可选*，默认为 `False`)：是否应在模型中添加交叉注意力层。

这是用于存储 EvollaModel 配置的类。它根据指定的参数实例化 Evolla 模型，并定义模型架构。使用默认值实例化配置将生成与 [westlake-repl/Evolla-10B-hf](https://huggingface.co/westlake-repl/Evolla-10B-hf) 类似的配置。

配置对象继承自 [PreTrainedConfig](/docs/transformers/main/zh/main_classes/configuration#transformers.PreTrainedConfig)，可用于控制模型输出。有关更多信息，请参阅 [PreTrainedConfig](/docs/transformers/main/zh/main_classes/configuration#transformers.PreTrainedConfig) 的文档。

示例：

```python
>>> from transformers import EvollaModel, EvollaConfig

>>> # Initializing a Evolla evolla-10b style configuration
>>> configuration = EvollaConfig()

>>> # Initializing a model from the evolla-10b style configuration
>>> model = EvollaModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

## EvollaModel[[transformers.EvollaModel]]

#### transformers.EvollaModel[[transformers.EvollaModel]]

```python
transformers.EvollaModel(config: EvollaConfig)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/modeling_evolla.py#L1273)

#### forward[[transformers.EvollaModel.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.Tensor] = None, position_ids: typing.Optional[torch.LongTensor] = None, cache: transformers.cache_utils.Cache | None = None, inputs_embeds: typing.Optional[torch.Tensor] = None, use_cache: bool | None = None, protein_input_ids: typing.Optional[torch.LongTensor] = None, protein_attention_mask: typing.Optional[torch.Tensor] = None, structure_feats: typing.Optional[torch.Tensor] = None, msa_feats: typing.Optional[torch.Tensor] = None, structure_batch_mask: typing.Optional[torch.Tensor] = None, msa_batch_mask: typing.Optional[torch.Tensor] = None, **kwargs)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/modeling_evolla.py#L1301)

**参数：**

input_ids (`torch.LongTensor`，形状为 `(batch_size, sequence_length)`，*可选*)：输入序列中 token 在词汇表中的索引。默认情况下，填充（padding）将被忽略。可以使用 [AutoTokenizer](/docs/transformers/main/zh/model_doc/auto#transformers.AutoTokenizer) 获取索引。有关详细信息，请参阅 [PreTrainedTokenizer.encode()](/docs/transformers/main/zh/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) 和 [PreTrainedTokenizer.__call__()](/docs/transformers/main/zh/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__)。[什么是输入 ID？](../glossary#input-ids)

attention_mask (`torch.Tensor`，形状为 `(batch_size, sequence_length)`，*可选*)：用于避免对填充（padding）标记索引执行注意力机制的掩码。掩码值取自 `[0, 1]`： - 1 表示**未掩码**的标记， - 0 表示**已掩码**的标记。 [什么是注意力掩码？](../glossary#attention-mask)

position_ids (`torch.LongTensor`，形状为 `(batch_size, sequence_length)`，*可选*)：输入序列中每个 token 在位置嵌入中的位置索引。取值范围为 `[0, config.n_positions - 1]`。[什么是位置 ID？](../glossary#position-ids)

cache (`~cache_utils.Cache`，*可选*)：预计算的隐藏状态（自注意力块和交叉注意力块中的键和值），可用于加速顺序解码。这通常指模型在解码的先前阶段返回的 `cache`，此时 `use_cache=True` 或 `config.use_cache=True`。 仅允许 [Cache](/docs/transformers/main/zh/internal/generation_utils#transformers.Cache) 实例作为输入，请参阅我们的 [kv cache 指南](https://huggingface.co/docs/transformers/en/kv_cache)。如果未传入 `cache`，则默认初始化 [DynamicCache](/docs/transformers/main/zh/internal/generation_utils#transformers.DynamicCache)。 模型将输出与输入格式相同的缓存。 如果使用 `cache`，则用户预期仅输入未处理的 `input_ids`（即未向此模型提供其过去键值状态的那些），其形状为 `(batch_size, unprocessed_length)`，而不是形状为 `(batch_size, sequence_length)` 的所有 `input_ids`。

inputs_embeds (`torch.Tensor`，形状为 `(batch_size, sequence_length, hidden_size)`，*可选*)：可选地，你可以选择直接传入嵌入表示，而不是传入 `input_ids`。如果你希望比模型内部的嵌入查找矩阵更精细地控制如何将 `input_ids` 索引转换为对应的向量，这将非常有用。

use_cache (`bool`, *可选*) : 如果设置为 `True`，则会返回 `cache` 键值状态，可用于加速解码（参见 `cache`）。

protein_input_ids (`torch.LongTensor`, *可选*) : 结构感知标记中蛋白质序列的输入 ID。形状应为 `(batch_size, protein_seq_length)`，类型为 `torch.LongTensor`。

protein_attention_mask (`torch.Tensor`, *可选*) : 蛋白质序列的注意力掩码。形状应为 `(batch_size, protein_seq_length)`，类型为 `torch.Tensor`。

structure_feats (`torch.Tensor`, *可选*) : 纯基于结构的特征的输入 ID。形状应为 `(batch_size, structure_seq_length, structure_feat_dim)`，类型为 `torch.Tensor`。目前为占位输入。

msa_feats (`torch.Tensor`, *可选*) : 纯基于 MSA 的特征的输入 ID。形状应为 `(batch_size, msa_seq_length, msa_feat_dim)`，类型为 `torch.Tensor`。目前为占位输入。

structure_batch_mask (`torch.Tensor`, *可选*) : 用于决定哪些蛋白质序列是纯基于结构的批次掩码。其形状应为 `(batch_size)`，类型为 `torch.Tensor`。应与 `structure_feats` 配对使用。目前为占位输入。

msa_batch_mask (`torch.Tensor`, *可选*) : 用于决定哪些蛋白质序列纯粹基于 MSA 的批次掩码。其形状应为 `(batch_size)`，类型为 `torch.Tensor`。应与 `msa_feats` 配对使用。目前为占位输入。

**返回：** [BaseModelOutputWithPast](/docs/transformers/main/zh/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast) 或 `tuple(torch.Tensor)`

一个 [BaseModelOutputWithPast](/docs/transformers/main/zh/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast) 或 `torch.Tensor` 元组（如果传入了 `return_dict=False` 或 `config.return_dict=False`），其包含的元素取决于配置（`None`）和输入。

[EvollaModel](/docs/transformers/main/zh/model_doc/evolla#transformers.EvollaModel) 的 forward 方法重写了 `__call__` 特殊方法。

尽管前向传播的实现需要在此函数中定义，但之后应调用 `Module` 实例，而不是直接调用此函数，因为前者会负责执行预处理和后处理步骤，而后者会静默地忽略这些步骤。

- **last_hidden_state**（形状为 `(batch_size, sequence_length, hidden_size)` 的 `torch.Tensor`）-- 模型最后一层输出的隐藏状态序列。

  如果使用了`cache`，则仅输出形状为`(batch_size, 1, hidden_size)`的序列的最后一个隐藏状态。
- **cache**（`Cache`，*可选*，在传入 `use_cache=True` 或 `config.use_cache=True` 时返回）-- 它是一个 [Cache](/docs/transformers/main/zh/internal/generation_utils#transformers.Cache) 实例。有关更多详细信息，请参阅我们的 [kv cache 指南](https://huggingface.co/docs/transformers/en/kv_cache)。

  包含预计算的隐藏状态（自注意力块中的键和值，以及如果 `config.is_encoder_decoder=True` 则还包括交叉注意力块中的键和值），可用于（参见 `cache` 输入）加速顺序解码。
- **hidden_states** (`tuple(torch.Tensor)`，*可选*，在传入 `output_hidden_states=True` 或 `config.output_hidden_states=True` 时返回) -- 一个 `torch.Tensor` 元组（如果模型具有嵌入层，则包含嵌入层的输出，以及每一层的输出），形状为 `(batch_size, sequence_length, hidden_size)`。

  模型在每一层输出处的隐藏状态，以及可选的初始嵌入输出。
- **attentions** (`tuple(torch.Tensor)`，*可选*，当传入 `output_attentions=True` 或 `config.output_attentions=True` 时返回) -- 一个 `torch.Tensor` 元组（每层一个），形状为 `(batch_size, num_heads, sequence_length, sequence_length)`。

  经过注意力 softmax 后的注意力权重，用于在自注意力头中计算加权平均值。

## EvollaForProteinText2Text[[transformers.EvollaForProteinText2Text]]

#### transformers.EvollaForProteinText2Text[[transformers.EvollaForProteinText2Text]]

```python
transformers.EvollaForProteinText2Text(config: EvollaConfig)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/modeling_evolla.py#L1401)

#### forward[[transformers.EvollaForProteinText2Text.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.Tensor] = None, inputs_embeds: typing.Optional[torch.Tensor] = None, labels: typing.Optional[torch.LongTensor] = None, protein_input_ids: typing.Optional[torch.LongTensor] = None, protein_attention_mask: typing.Optional[torch.Tensor] = None, use_cache: bool | None = None, logits_to_keep: typing.Union[int, torch.Tensor] = 0, **kwargs)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/modeling_evolla.py#L1416)

**参数：**

input_ids (`torch.LongTensor`，形状为 `(batch_size, sequence_length)`，*可选*)：输入序列中 token 在词汇表中的索引。默认情况下，填充（padding）将被忽略。可以使用 [AutoTokenizer](/docs/transformers/main/zh/model_doc/auto#transformers.AutoTokenizer) 获取索引。有关详细信息，请参阅 [PreTrainedTokenizer.encode()](/docs/transformers/main/zh/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) 和 [PreTrainedTokenizer.__call__()](/docs/transformers/main/zh/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__)。[什么是输入 ID？](../glossary#input-ids)

attention_mask (`torch.Tensor`，形状为 `(batch_size, sequence_length)`，*可选*)：用于避免对填充（padding）标记索引执行注意力机制的掩码。掩码值取自 `[0, 1]`： - 1 表示**未掩码**的标记， - 0 表示**已掩码**的标记。 [什么是注意力掩码？](../glossary#attention-mask)

inputs_embeds (`torch.Tensor`，形状为 `(batch_size, sequence_length, hidden_size)`，*可选*)：可选地，你可以选择直接传入嵌入表示，而不是传入 `input_ids`。如果你希望比模型内部的嵌入查找矩阵更精细地控制如何将 `input_ids` 索引转换为对应的向量，这将非常有用。

labels (`torch.LongTensor`，形状为 `(batch_size, sequence_length)`，*可选*)：用于计算掩码语言建模损失的标签。索引值应在 `[0, ..., config.vocab_size]` 范围内，或为 -100（参见 `input_ids` 的文档字符串）。索引值设为 `-100` 的 token 将被忽略（即被掩码），损失仅针对标签在 `[0, ..., config.vocab_size]` 范围内的 token 进行计算。

protein_input_ids (`torch.LongTensor`, *可选*) : 蛋白质序列的输入 ID。形状应为 `(batch_size, protein_seq_length)`，类型为 `torch.LongTensor`。

protein_attention_mask (`torch.Tensor`, *可选*) : 蛋白质序列的注意力掩码。形状应为 `(batch_size, protein_seq_length)`，类型为 `torch.Tensor`。

use_cache (`bool`, *可选*) : 如果设置为 `True`，则会返回 `cache` 键值状态，可用于加速解码（参见 `cache`）。

logits_to_keep (`Union[int, torch.Tensor]`，*可选*，默认为 `0`)：如果为 `int`，则计算最后 `logits_to_keep` 个 token 的 logits。如果为 `0`，则计算所有 `input_ids` 的 logits（特殊情况）。生成过程只需要最后一个 token 的 logits，仅针对该 token 进行计算可以节省内存，对于长序列或大词汇量而言，这种节省相当可观。如果为 `torch.Tensor`，则必须是一维张量，对应于序列长度维度中需要保留的索引。这在使用打包张量格式（将批次和序列长度合并为单一维度）时非常有用。

[EvollaForProteinText2Text](/docs/transformers/main/zh/model_doc/evolla#transformers.EvollaForProteinText2Text) 的 forward 方法重写了 `__call__` 特殊方法。

尽管前向传播的实现需要在此函数中定义，但之后应调用 `Module` 实例，而不是直接调用此函数，因为前者会负责执行预处理和后处理步骤，而后者会静默地忽略这些步骤。

示例：

```python
>>> from transformers import EvollaProcessor, EvollaForProteinText2Text
>>> model = EvollaForProteinText2Text.from_pretrained("westlake/Evolla-10B-hf")
>>> processor = EvollaProcessor.from_pretrained("westlake/Evolla-10B-hf")

>>> protein_information = {
    "aa_seq": "your amino acid sequence",
    "foldseek": "your foldseek sequence",
}
>>> question = "What is the function of this protein?"
>>> message = [
    {"role": "system", "content": "You are an AI expert that can answer any questions about protein."},
    {"role": "user", "content": question},
]

>>> inputs = processor(proteins=[protein_information], messages_list=[message], return_tensors="pt", padding="longest")
>>> outputs = model.generate(**inputs)

>>> print(processor.batch_decode(outputs, skip_special_tokens=True))
```

## EvollaProcessor[[transformers.EvollaProcessor]]

#### transformers.EvollaProcessor[[transformers.EvollaProcessor]]

```python
transformers.EvollaProcessor(protein_tokenizer, tokenizer = None, protein_max_length = 1024, text_max_length = 512, **kwargs)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/processing_evolla.py#L27)

**参数：**

protein_tokenizer (`EsmTokenizer`)：[EsmTokenizer](/docs/transformers/main/zh/model_doc/esm#transformers.EsmTokenizer) 的实例。蛋白质分词器是必需的输入。

tokenizer (`tokenizer_class`)：分词器是必需的输入。

protein_max_length (`int`，*可选*，默认为 1024)：要生成的序列的最大长度。

text_max_length (`int`，*可选*，默认值为 512)：要生成的文本的最大长度。

构造一个 EvollaProcessor，它将蛋白质分词器和分词器封装为单个处理器。

[EvollaProcessor](/docs/transformers/main/zh/model_doc/evolla#transformers.EvollaProcessor) 提供了 `{protein_tokenizer_class}` 和 `tokenizer_class` 的所有功能。有关更多信息，请参阅 `~{protein_tokenizer_class}` 和 `~tokenizer_class`。

#### __调用__[[transformers.EvollaProcessor.__call__]]

```python
__call__(proteins: list[dict] | dict | None = None, messages_list: list[list[dict]] | list[dict] | None = None, protein_max_length: int | None = None, text_max_length: int | None = None, **kwargs)
```

[来源](https://github.com/huggingface/transformers/blob/main/src/transformers/models/evolla/processing_evolla.py#L85)

**参数：**

proteins (`Union[List[dict], dict]`) : 包含以下键的字典列表或单个字典： - `"aa_seq"` (`str`) -- 蛋白质的氨基酸序列。 - `"foldseek"` (`str`) -- 蛋白质的 foldseek 字符串。

messages_list (`Union[List[List[dict]], List[dict]]`) : 字典的列表的列表，或包含以下键的字典列表： - `"role"` (`str`) -- 消息的角色。 - `"content"` (`str`) -- 消息的内容。

protein_max_length (`int`，*可选*，默认为 1024)：要生成的序列的最大长度。

text_max_length (`int`，*可选*，默认为 512)：文本的最大长度。

return_tensors (`str` 或 [TensorType](/docs/transformers/main/zh/internal/file_utils#transformers.TensorType)，*可选*)：如果设置，将返回特定框架的张量。可接受的值为： - `'pt'`：返回 PyTorch `torch.Tensor` 对象。 - `'np'`：返回 NumPy `np.ndarray` 对象。

**返回：** `a dict with following keys`

- `protein_input_ids`（形状为 `(batch_size, sequence_length)` 的 `torch.Tensor`）-- 蛋白质序列的输入 ID。
- `protein_attention_mask` (`torch.Tensor`，形状为 `(batch_size, sequence_length)`) -- 蛋白质序列的注意力掩码。
- `text_input_ids`（形状为 `(batch_size, sequence_length)` 的 `torch.Tensor`）-- 文本序列的输入 ID。
- `text_attention_mask` (`torch.Tensor`，形状为 `(batch_size, sequence_length)`) -- 文本序列的注意力掩码。

