Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

接入一个新的模型需要满足哪些条件 #44

Open
@klxqlehua

Description

@klxqlehua

你好,这篇文章和代码实现细看了下,如果我想接入一个新的模型来支持infLLM,需要哪些满足条件,个人理解:

  1. 位置编码:新的模型attention内部也必须是RotaryEmbeddingESM编码方式,否则训练的模型与infLLM推理在位置编码等效性上就不一致了;
  2. 新模型的model.model.forward与InfLLM的model_forward的实现逻辑必须完全一样;
  3. 新模型的Attention的推理计算入参格式必须满足如下
    def forward(
    self,
    hidden_states: torch.Tensor,
    attention_mask: Optional[torch.Tensor] = None,
    position_ids: Optional[torch.LongTensor] = None,
    past_key_value: Optional[Cache] = None,
    output_attentions: bool = False,
    use_cache: bool = False,
    **kwargs,
    ) ,目的是为了与InfLLM定义的hf_forward的入参完全保持一致;
    感觉应该够了,对吧,还需要其他硬性满足条件吗?
    如确实如此,那么接入一个新的开源模型应该很容易对吧?为什么我看你这边只接入了LlamaForCausalLM,MistralForCausalLM,Qwen2ForCausalLM这三个?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp