1. 19 Apr, 2024 1 commit
  2. 18 Apr, 2024 1 commit
    • tomeras91's avatar
      Add jamba (#29943) · 3f20877d
      tomeras91 authored
      * Add jamba arch
      
      * apply "make fix-copies" changes
      
      * fix link to model in JambaConfig docstring
      
      * Add n_ctx in modeling file because repo-consistency wants that
      
      * Add jamba to flash attention and sdpa documentation
      
      * mamba dt_proj quant fix now works for LoRA as well
      
      * override test_left_padding_compatibility and use a more permissive tolerance. left padding numerical difference are accentuated by mamba layers
      
      * add jamba to tokenization auto
      
      * fix comments of shape (PR #24 in the model page: https://huggingface.co/ai21labs/Jamba-v0.1/discussions/24)
      
      * simple PR fixes
      
      * remove unnecessary kwargs from JambaAttentionDecoderLayer and JambaMambaDecoderLayer
      
      * remove the LoRA hack for the mamba dt_proj bias. It was solved in huggingface/peft#1530 (https://github.com/huggingface/peft/pull/1530)
      
      * Add copied comment on JambaMLP (it's the same as MixtralMLP)
      
      * remove padding_mask warnings. It's not supported anymore
      
      * fix docstring. Float instead of int
      
      * A few more minor PR fixes
      
      * (1) lowercase names for mamba layernorms (2) remove _apply_inner_layernorms and do it directly in the forward pass
      
      * Return None attention weights from mamba layers. Append to all attentions only if not None.
      
      * remove some leftover jamba archive lists
      
      * Better separation between expert vs non-expert layers. non-expert layers return None as router_logits, and it is not concatenated to all_router_logits returned from JambaModel
      
      * no need to take router_logits at config.expert_layer_offset anymore. result.router_logits now holds results only for expert layers
      
      * Add Jamba paper on READMEs
      
      * (1) rename n_ctx -> max_position_embeddings (2) don't use it in the modeling file since it's not needed (set it as an exception to check_config_attributes)
      
      * Add copied from comment
      
      * remove the code path for apply_inner_layernorms=False. Jamba always has the inner mamba layernorms
      
      * clearer docstring for _convert_to_standard_cache
      
      * style fixes
      
      * Change calc_logits_for_entire_prompt (bool) to num_logits_to_keep (int). Adapt assisted decoding code tp use it. Also small change in low memory beam search decoding path to support this new int value in model_inputs
      
      * rename test so it still overrides what its meant to override
      
      * draft
      
      * oups
      
      * nit
      
      * remove more complexe logic
      
      * fix names used in config
      
      * fix fix fix
      
      * style
      
      * fix some more failing tests
      
      * generate did not init the cache 馃檭
      
      
      
      * more small nits
      
      * typo
      
      * config.mamba_expand * config.hidden_size for the intermediate size of the mamba shapes
      
      * fix init of pkv with torch.tensor()
      
      * empty tensor
      
      * fix some init issues
      
      * stupid changes required by generate because it does not even support it's own DynamicCache class
      
      * more fixes
      
      * fix general assisted gen cache_position bug
      
      * tests passing
      
      * Add offsets and periods as SPECIAL_CASES_TO_ALLOW in check_config_attributes.py
      
      * fix reorder_cache to reorder mamba states and override some more functions in HybridMambaAttentionDynamicCache
      
      * no need to override test_past_key_values_format() and _check_past_key_values_for_generate() in tests anymore
      
      * fix docstrings and typehints for past_key_values
      
      * style fixes
      
      * fix docs
      
      * change typehint due to copy from Mixtral
      
      * forgot import
      
      * import order
      
      * Add configuration_jamba and modeling_jamba to not_doctested because the model is too big to download (in docstring of JambaForCausalLM.forward)
      
      * Add integration test with tiny tandom Jamba model on hub
      
      * fix flash attention cache shapes
      
      * bring back forgotten hidden states
      
      * rename HybridMambaAttentionDynamicCache.seqlen_offset to has_previous_state (and make bool) and bugfix - it should be set to True after a finished forward pass of the entire model
      
      * align integration test after modeling fixes
      
      * bugfix - mamba can use precomputed states only of forward pass is on a single token
      
      * bugfix - mamba can use precomputed states only if they match the batch size
      
      * typo
      
      * remove making _prepare_4d_causal_attention_mask a leaf function
      
      * stop using past_seq_len.get_seq_length(). Use cache positions instead. Adjust test (test_decoder_model_past_with_large_inputs) accordingly
      
      ---------
      Co-authored-by: default avatarArthur Zucker <arthur.zucker@gmail.com>
      Co-authored-by: default avatarJoao Gante <joao@huggingface.co>
      3f20877d
  3. 10 Apr, 2024 1 commit
  4. 09 Apr, 2024 1 commit
  5. 08 Apr, 2024 1 commit
  6. 02 Apr, 2024 2 commits
    • th茅o gigant's avatar
      Adding FlaxNoRepeatNGramLogitsProcessor (#29677) · fed27ffc
      th茅o gigant authored
      * fix issue with logit processor in beam search in Flax
      
      * adding FlaxNoRepeatNGramLogitsProcessor class + unit test
      
      * style correction and code verification
      
      * add FlaxNoRepeatNGramLogitsProcessor to the test_processor_list and test_processor_list_jitted tests
      
      * fix an issue where ngrams are banned only if they appear ==1 time + update description of get_previous_ngrams
      
      * replace non-jit compatible masking of ngrams that are not yet generated with jittable version
      
      * Revert "fix issue with logit processor in beam search in Flax"
      
      This reverts commit 09b70d7e4dc32d0cc4db61af09a835a9cd238b50.
      
      * add FlaxNoRepeatNGramLogitsProcessor to _get_logits_processor
      
      * change the method of casting to boolean of banned tokens indices
      
      * fix code style
      
      * remove some useless operations + significantly faster computation of update indices using jax.lax.fori_loop
      
      * remove useless loop iterations
      
      * set some variables that were calculated and used multiple times
      
      * fix format
      fed27ffc
    • Arthur's avatar
      [`generate`] fix breaking change for patch (#29976) · 83b26dd7
      Arthur authored
      * fix bug and add tests
      
      * nit
      
      * otherway to get the cur len instead of attention mask
      
      * more places where this might have been broken
      
      * nit
      
      * oups
      
      * inputs_embeds vs input_embeds
      
      * test generated outptus
      
      * style
      
      * nit
      
      * fix
      
      * skip failing biogpt
      83b26dd7
  7. 01 Apr, 2024 1 commit
  8. 27 Mar, 2024 1 commit
  9. 26 Mar, 2024 1 commit
  10. 21 Mar, 2024 1 commit
  11. 19 Mar, 2024 1 commit
  12. 08 Mar, 2024 2 commits
  13. 07 Mar, 2024 1 commit
  14. 06 Mar, 2024 1 commit
  15. 27 Feb, 2024 1 commit
  16. 26 Feb, 2024 1 commit
  17. 20 Feb, 2024 1 commit
  18. 19 Feb, 2024 1 commit
    • Max Baak's avatar
      ENH: added new output_logits option to generate function (#28667) · 08cd694e
      Max Baak authored
      output_logits option behaves like output_scores, but returns the raw, unprocessed prediction logit scores,
      ie. the values before they undergo logit processing and/or warping. The latter happens by default for the
      regular output scores.
      
      It's useful to have the unprocessed logit scores in certain circumstances. For example, unprocessed logit scores
      are very useful with causallm models when one wants to determine the probability of a certain answer, e.g.
      when asking a question with a yes/no answer. In that case getting the next-token probabilities of both "yes" and
      "no" (and/or their relative ratio) is of interest for classification. The reason for getting these _before_ logit
      processing and/or warping is b/c a) that can change the probabilities or b) reject the tokens of interest / reduce
      the number of tokens to just 1.
      
      For an example use-case see paper TabLLM: Few-shot Classification of Tabular Data with Large Language Models
      by Stefan Hegselmann, Alejandro Buendia, Hunter Lang, Monica Agrawal, Xiaoyi Jiang, and David Sontag.
      https://arxiv.org/abs/2210.10723
      
      
      
      In addition:
      - added dedicated unit test: tests/generation/test_utils/test_return_unprocessed_logit_scores
        which tests return of logics with output_logits=True in generation.
      - set output_logits=True in all other generation unit tests, that also have output_scores=True.
      
      Implemented @gante's and @amyeroberts review feedback
      Co-authored-by: default avatarkx79wq <max.baak@ing.com>
      08cd694e
  19. 16 Feb, 2024 3 commits
  20. 08 Feb, 2024 1 commit
  21. 30 Jan, 2024 1 commit
    • Matt's avatar
      Add tf_keras imports to prepare for Keras 3 (#28588) · 415e9a09
      Matt authored
      * Port core files + ESM (because ESM code is odd)
      
      * Search-replace in modelling code
      
      * Fix up transfo_xl as well
      
      * Fix other core files + tests (still need to add correct import to tests)
      
      * Fix cookiecutter
      
      * make fixup, fix imports in some more core files
      
      * Auto-add imports to tests
      
      * Cleanup, add imports to sagemaker tests
      
      * Use correct exception for importing tf_keras
      
      * Fixes in modeling_tf_utils
      
      * make fixup
      
      * Correct version parsing code
      
      * Ensure the pipeline tests correctly revert to float32 after each test
      
      * Ensure the pipeline tests correctly revert to float32 after each test
      
      * More tf.keras -> keras
      
      * Add dtype cast
      
      * Better imports of tf_keras
      
      * Add a cast for tf.assign, just in case
      
      * Fix callback imports
      415e9a09
  22. 29 Jan, 2024 1 commit
  23. 19 Jan, 2024 2 commits
  24. 16 Jan, 2024 1 commit
  25. 15 Jan, 2024 1 commit
  26. 13 Jan, 2024 1 commit
  27. 12 Jan, 2024 1 commit
  28. 10 Jan, 2024 1 commit
  29. 14 Dec, 2023 1 commit
  30. 08 Dec, 2023 3 commits
    • Xin Qiu's avatar
      Fix remaining issues in beam score calculation (#27808) · b31905d1
      Xin Qiu authored
      * Fix issues in add and is_done for BeamHypotheses
      
      * make newly added arguments optional for better compatibility
      
      * Directly use cur_len as generated_len, add note for retrocompatibility
      
      * update test expectation
      
      * make cur_len represents the length of the entire sequence including the decoder prompt
      
      * remove redundant if/else in testing
      b31905d1
    • Saibo-creator's avatar
      Fix: Raise informative exception when `prefix_allowed_tokens_fn` return empty... · 56be5e80
      Saibo-creator authored
      
      Fix: Raise informative exception when `prefix_allowed_tokens_fn` return empty set of tokens (#27797)
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      56be5e80
    • Tom Aarsen's avatar
      Generate: New `Cache` abstraction and Attention Sinks support (#26681) · 633215ba
      Tom Aarsen authored
      * Draft version of new KV Caching
      
      This should allow Attention Sinks (https://github.com/tomaarsen/attention_sinks)
      / StreamingLLM (https://arxiv.org/abs/2309.17453) to be easily implemented
      in a third-party or in transformers directly
      
      * Address numerous PR suggestions
      
      1. Move layer_idx from cache to ...Attention. Removes confusing set_layer_idx magic.
      2. Always convert past_key_values to Cache instance at the start of ...Attention, removes all other isinstance calls.
      3. Remove __bool__ and __getitem__ magic as they're confusing.
      4. past_key_values.update(key, value, idx) now returns key, value.
      5. Add use_legacy_cache flag, defaults to None, i.e. Falsey. This breaks generate for now, until 1) the cache is used is generate() or 2) use_legacy_cache is defaulted to True in generate() until we change it in another PR.
      6. Separate key_cache and value_cache.
      
      Some work is still needed to see if the SinkCache can conveniently be implemented with just one update method.
      
      * Implement the SinkCache through backward+forward rotations
      
      * Integrate (Sink)Cache with Llama FA2
      
      * Set use_legacy_cache=True as default, allows for test passes
      
      * Move from/to_legacy_cache to ...Model class
      
      * Undo unnecessary newline change
      
      * Remove copy utility from deprecated OpenLlama
      
      * Match import style
      
      * manual rebase with main
      
      * Cache class working with generate (#1)
      
      * Draft version of new KV Caching
      
      This should allow Attention Sinks (https://github.com/tomaarsen/attention_sinks)
      / StreamingLLM (https://arxiv.org/abs/2309.17453
      
      ) to be easily implemented
      in a third-party or in transformers directly
      
      * Address numerous PR suggestions
      
      1. Move layer_idx from cache to ...Attention. Removes confusing set_layer_idx magic.
      2. Always convert past_key_values to Cache instance at the start of ...Attention, removes all other isinstance calls.
      3. Remove __bool__ and __getitem__ magic as they're confusing.
      4. past_key_values.update(key, value, idx) now returns key, value.
      5. Add use_legacy_cache flag, defaults to None, i.e. Falsey. This breaks generate for now, until 1) the cache is used is generate() or 2) use_legacy_cache is defaulted to True in generate() until we change it in another PR.
      6. Separate key_cache and value_cache.
      
      Some work is still needed to see if the SinkCache can conveniently be implemented with just one update method.
      
      * Integrate (Sink)Cache with Llama FA2
      
      * Move from/to_legacy_cache to ...Model class
      
      * Undo unnecessary newline change
      
      * Match import style
      
      * working generate
      
      * Add tests; Simplify code; Apply changes to Mistral and Persimmon
      
      * fix rebase mess
      
      * a few more manual fixes
      
      * last manual fix
      
      * propagate changes to phi
      
      * upgrade test
      
      * add use_legacy_cache docstring; beef up tests
      
      * reintroduce unwanted deletes
      
      ---------
      Co-authored-by: default avatarTom Aarsen <Cubiegamedev@gmail.com>
      
      * move import
      
      * add default to model_kwargs.get('use_legacy_cache')
      
      * correct failing test
      
      * Apply suggestions from code review
      Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>
      
      * apply PR suggestions
      
      * fix failing test
      
      * Apply suggestions from code review
      Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>
      Co-authored-by: default avatarTom Aarsen <37621491+tomaarsen@users.noreply.github.com>
      
      * PR comments
      
      * tmp commit
      
      * add docstrings
      
      * more tests, more docstrings, add to docs
      
      * derp
      
      * tmp commit
      
      * tmp dbg
      
      * more dbg
      
      * fix beam search bug
      
      * cache can be a list of tuples in some models
      
      * fix group beam search
      
      * all but sinkcache integration tests
      
      * fix sink cache and add hard integration test
      
      * now also compatible with input_embeds input
      
      * PR comments
      
      * add Cache support to Phi+FA2
      
      * make fixup
      
      ---------
      Co-authored-by: default avatarJoao Gante <joao@huggingface.co>
      Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>
      Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>
      633215ba
  31. 30 Nov, 2023 1 commit
  32. 24 Nov, 2023 1 commit
  33. 17 Nov, 2023 1 commit