Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dose num_logits_to_keep in model.generate() really work? #35629

Open
2 of 4 tasks
bwnjnOEI opened this issue Jan 11, 2025 · 0 comments
Open
2 of 4 tasks

Dose num_logits_to_keep in model.generate() really work? #35629

bwnjnOEI opened this issue Jan 11, 2025 · 0 comments
Labels

Comments

@bwnjnOEI
Copy link

bwnjnOEI commented Jan 11, 2025

System Info

  • transformers version: 4.47.1
  • Platform: Linux-6.9.3-76060903-generic-x86_64-with-glibc2.35
  • Python version: 3.10.14
  • Huggingface_hub version: 0.27.0
  • Safetensors version: 0.5.0
  • Accelerate version: 1.2.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.5.1+cu124 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?:
  • Using GPU in script?:
  • GPU type: NVIDIA GeForce RTX 4090

Who can help?

@zucchini-nlp @gante @ArthurZucker

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

I want to customize the num_logits_to_keep in LlamaForCausalLM's forward function by setting it through generate, but I failed or don't know how to check the logits of tokens produced by num_logits_to_keep.

a code snippet

outputs = model.generate( 
    ids['input_ids'],
    max_new_tokens=50,
    pad_token_id=tokenizer.eos_token_id,
    output_scores=True,
    return_dict_in_generate=True,
    num_logits_to_keep=3,
)

or

model.generation_config.num_logits_to_keep = 3

Expected behavior

outputs.logits != None ?

@bwnjnOEI bwnjnOEI added the bug label Jan 11, 2025
@bwnjnOEI bwnjnOEI changed the title How to correctly use num_logits_to_keep in model.generate()? Dose num_logits_to_keep in model.generate() really work? Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant