Git Product home page Git Product logo

mbr's People

Contributors

jvamvas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mbr's Issues

Incompatible with transformers>=4.39

The decoding code is currently not compatible with versions of Hugging Face transformers >= v4.39:

======================================================================
ERROR: test_generate (test_generate.DecoderOnlyTestCase.test_generate)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/mbr/mbr/tests/test_generate.py", line 28, in test_generate
    output = self.model.generate(
             ^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/mbr/generation/utils.py", line 344, in generate
    generation_mode = self._get_generation_mode(generation_config, assistant_model)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1709, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'MBRGPT2LMHeadModel' object has no attribute '_get_generation_mode'

Tensor Index Issue with HF generate's num_return_sequences > 1

Currently running into an issue that arises whenever the num_return_sequences > 1. Otherwise the code works when num_return_sequences=1:

mbr_bart = MBR(BartForConditionalGeneration).from_pretrained("mymodel")
mbr_config = MBRConfig(
            num_samples=5,
        )

inps = bart_tokenizer(src, return_tensors='pt').to('cuda')
mbr_bart.generate(**inps, do_sample=True, mbr_config=mbr_config, tokenizer=bart_tokenizer, num_beams=1, num_return_sequences=2, max_new_tokens=25, epsilon_cutoff=0.02)

-----------------------------------------------------------------------------------------------------------------------

IndexError                                Traceback (most recent call last)
Cell In[66], line 24
     18 mbr_config = MBRConfig(
     19             num_samples=5,
     20         )
     23 inps = bart_tokenizer(src, return_tensors='pt').to('cuda')
---> 24 mbr_bart.generate(**inps, do_sample=True, mbr_config=mbr_config, tokenizer=bart_tokenizer, num_beams=1, num_return_sequences=2, max_new_tokens=25, epsilon_cutoff=0.02)

File ~/.local/lib/python3.9/site-packages/torch/utils/_contextlib.py:115, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    112 @functools.wraps(func)
    113 def decorate_context(*args, **kwargs):
    114     with ctx_factory():
--> 115         return func(*args, **kwargs)

File ~/.local/lib/python3.9/site-packages/mbr/generation/utils.py:506, in MBRGenerationMixin.generate(self, inputs, generation_config, references_config, mbr_config, tokenizer, metric_runner, logits_processor, stopping_criteria, prefix_allowed_tokens_fn, synced_gpus, assistant_model, streamer, negative_prompt_ids, negative_prompt_attention_mask, progress_bar, **kwargs)
    498 output = MBROutput(
    499     sequences=generation_config.pad_token_id * torch.ones((batch_size, max_length), dtype=torch.long),
    500     all_samples=(tuple(samples) if mbr_config.output_all_samples else None),
   (...)
    503     metric_scores=(metric_output if mbr_config.output_metric_scores else None),
    504 )
    505 for batch_idx, sample_idx in enumerate(top_metric_indices):
--> 506     output.sequences[batch_idx][:sample_ids[sample_idx].shape[1]] = sample_ids[sample_idx][batch_idx]
    508 if mbr_config.return_dict_in_generate:
    509     return output

IndexError: index 1 is out of bounds for dimension 0 with size 1

Thank you for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.