Skip to content

feat: default max_seq_length to 2048 for ONNX embedding backend #472

Closed

Description

@ajianaz

Problem

Current default max_seq_length for the ONNX embedding backend is 256 tokens. This is too low for practical use cases:

  • Knowledge base entries with moderate text (~200-500 words) get truncated
  • Document chunks, code snippets, and technical descriptions often exceed 256 tokens
  • Forces users to manually set max_seq_length = 2048 in uteke.toml after every setup

Proposal

Change the default max_seq_length to 2048 for the ONNX embedding backend.

This aligns with:

  • CodeCora Embed API (deployed on Modal) which defaults to 2048
  • Common embedding API standards (OpenAI text-embedding-3-small supports up to 8191)
  • EmbeddingGemma model native capacity (supports up to 4096)

Config Change

[embedding]
# Before (implicit default)
max_seq_length = 256  # too low

# After (new default)
max_seq_length = 2048  # aligns with Modal API & practical use

User should still be able to override via uteke.toml:

  • max_seq_length = 512 — for faster short-text use cases
  • max_seq_length = 4096 — for long document chunks

Impact

  • Latency: Slight increase for short texts (256 → 2048 padding), but ONNX Q4 is fast enough (~0.93s → ~1.1s single embed)
  • Memory: No change (ONNX runtime processes same tensors, just more non-zero positions)
  • Compatibility: Requires uteke repair for existing users (re-embed with new max_seq_length)

Environment Variable

Also support UTEKE_MAX_SEQ_LENGTH env var override (consistent with other embedding config vars).

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