OpenNMT / OpenNMT/CTranslate2

how to obtain get past_kv_cache values?

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

Nobody has claimed this yet.

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

Description

In hugging face autoclass models, we can do model.forward to obtain both logits and past_key_values. The model.generate then uses these past_key_values for efficient gen.

How can I return these past_key_values in generator.forward_batch api?

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 at the generator.forward_batch API and compare its outputs with the Hugging Face model.forward and model.generate handling of past_key_values. Determine the intended cache representation and lifecycle; done means the API provides a usable way to return those values.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, huggingface
Domain
backend-api-design, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.