OpenNMT / OpenNMT/CTranslate2

Different generation parameters in the same batch

Open
#1,209 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
4.7k
Forks
536
Avg merge
12h 12m
Merged PRs (30d)
4

Description

Hello team,

Today, batch generation works like the HF generate() function: it accepts several input texts but generation parameters (like temperature, top k, etc.) apply to the whole batch, so it is not possible to use different parameters within the same batch.

Is it because using different parameters in the same batch would degrade performance so much that it would defeat the purpose of batch generation?

Ideally it would be awesome if one could do something like this:

generator.generate_batch([
    {"input":input_1, "max_length":30, "sampling_topk":10},
    {"input":input_2, "max_length":150, "sampling_topk":50},
    {"input":input_3, "max_length":10, "sampling_topk":50},
    ...
])

For example this is something that can be achieved with NVIDIA Faster Transformers: https://github.com/NVIDIA/FasterTransformer/blob/main/examples/pytorch/gpt/gpt_example.py

Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the batch-generation entry point behind generator.generate_batch and compare its current parameter handling with the per-input example in the issue. Use the FasterTransformer reference to investigate whether per-item max_length and sampling parameters can be supported, and define completion around accepting the proposed input shape without unacceptable batch-performance degradation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.