Skip to content

[Feature]: Add Qwen3-Embedding model support (0.6B/4B/8B) for LLM API encode_only mode #14715

Open

Description

@anurags25

🚀 The feature, motivation and pitch

Native support for the Qwen3-Embedding model family (0.6B, 4B, 8B) for use with the LLM API's encode_only mode.

Problem

The Qwen3 embedding models don't work correctly out of the box with encode_only. TensorRT-LLM returns logits (post lm_head), whereas the correct output should be the last prompt token's hidden state before the lm_head (model card's transformers usage)

Proposed support

Add a new architecture/model class, e.g. Qwen3ForEmbedding, for use with LLM(..., encode_only=True).

The model class would:

  • Reuse the existing Qwen3 transformer backbone without applying lm_head.
  • Return last prompt token's hidden states from LLM.encode(...) instead of logits.
  • Leave normalization and MRL/custom-dimension slicing to the caller or serving layer.

Alternatives

No response

Additional context

Models: Qwen3-Embedding-0.6B, Qwen3-Embedding-4B, Qwen3-Embedding-8B

I'm happy to contribute a PR for this feature

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Activity

  1. added
    feature request
    on May 29, 2026
  2. added
    LLM API
    Model customization
    on May 29, 2026
  3. Priyanshu31102003 commented on May 29, 2026

    @Priyanshu31102003

    Hi team, I am interested in implementing support for Qwen3-Embedding models in encode_only mode within the Qwen model architecture.

    I have already analyzed qwen/model.py and qwen/config.py to draft the head bypass logic and conditional architecture flags. I will be working on a PR for this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

LLM APIModel customizationfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions