Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Pranav Mahajan
    @PranavMahajan25

    Hi, I am trying to get acquainted with Trax through the quickstart notebooks and wanted to use trax/rl. How do I use ppo_trainer with a custom gym env? I looked at trax/rl/ppo_trainer_test.py for reference.
    (Issues similar to this: https://colab.research.google.com/drive/1TnYMIt7Zm-iCN-Az3jeO8QoIpQ7YvHiD)

    Also I eventually want to build a simple DQN which can use transformer_decoder as the model, how should I go about, does transformer always expect inputs as in trax/rl/supervised/inputs.py ? How do I include states and actions both in the training stream? Any guidance/resources would be very helpful, TIA.

    Afroz Mohiuddin
    @afrozenator

    Hi @PranavMahajan25 - thanks for trying it out! We'd be very interested in taking the colab as an example of RL once it works.

    I ran the colab and it doesn't error out for me! So looks like you got it working (maybe don't use the same object with a different net since there may have been some caching of weights it looks like?)

    PS: I like the idea of starting with the test and modifying it in place to get what you want :)

    Re: states and actions both in traning stream @koz4k added some code for doing similar things in the rl/ directory, mostly related to simple.py. That part of the code is under heavy development, we want to try something similar as well.

    PPS: The colab uses trax 1.0.0, maybe upgrade to the latest 1.2.2?

    -

    Suraj Patil
    @patil-suraj
    Hello, is it possible to use Reformer for question answering task ? The input could be a whole chapter of the book. Is Reformer suited for this kind of task ?
    Pranav Mahajan
    @PranavMahajan25
    Thanks for your reply! @afrozenator. I would love to contribute to such an example, if it works out well.
    You were right, the error was because I used the same object with a different net. I'll explore the functions related to training streams and mixing streams from SimPLe. Thanks again!
    Afroz Mohiuddin
    @afrozenator
    Hi @patil-suraj - you could probably concatenate <document text>, <query> and <answer> with a special token, and mask the loss to only consider the answer tokens. So ultimately the target would look like <document text><sep1><query><sep2><answer> and set the loss mask to only operate on the answer tokens. Does it make sense? @nkitaev is making a Reformer encoder and things will look like seq2seq with that.
    Also scroll a little up where we discuss almost the same thing wrt summarization and see what Lukasz had to say as well
    Christopher Beitel
    @cwbeitel
    Just wanted to chime in to say we are really excited to be making use of Trax in the Project Clarify (https://github.com/projectclarify/clarify) codebase and would like to invite anyone with experience with Trax or Jax and interest in mentoring to come give a tutorial session at one of our upcoming hackathon/training days (Jan 25th and Feb 29): https://forms.gle/oFWkN7UuAxS7NUGJ9 Especially you @afrozenator, didn't have your email to send you an invite. Looking forward to adding value to Trax as we get up to speed with using it.
    NGamma
    @NGamma
    Hi! I'm running the Reformer example, incredible results on text generation. Could you point me in the right direction on how to modify the colab so it can take a dataset with many example .txt files of same text length 0.5M tokens on a single TPU?
    nkitaev
    @nkitaev
    Thanks! If you're running the colab example, you can modify the my_inputs to yield a different example each time.
    Right now IDS and PAD_AMOUNT are global constants that are constructed by loading a txt file of Crime and Punishment. You can instead load multiple txt files, apply the tokenizer, and then generate corresponding token ids for each one
    NGamma
    @NGamma
    @nkitaev I think I got it. I'll try that! Thank you!
    Suraj Patil
    @patil-suraj
    @afrozenator Yes it makes sense. Looking forward to the Reformer Encoder. Will try this approach out and if successful will post a tutorial about it. Thank you!
    Also I've recently came across Trax and it seems very interesting and clean. But I'm wondering why do we need another DL library when we already have TF2.0, also what are the advantages of Trax over TF2.0 and what are the design goals for Trax. @afrozenator @lukaszkaiser would like to know your thoughts on this
    AlDante
    @AlDante

    Hi, thank you for making Reformer and Trax available.

    I have a question regarding the TPU Crime and Punishment example. The language model obviously learns made-up words - scandlchedness , raggong, innatummed , quisten... Some great words there, but...

    Is this an artifact of the hashing, or what do you think causes it?

    nkitaev
    @nkitaev
    The hyperparameters in that demo are designed to run in about half an hour, not to yield optimal results
    It's very close to a character-level language model (only 320 basic tokens -- just enough to cover characters, character pairs, and maybe a few frequent words). It's also only training for 600 steps with minimal regularization.
    For comparison, BERT trains for 1 million steps, with a fair bit of dropout, on more diverse data
    AlDante
    @AlDante
    @nkitaev Thank you very much for clarifying.
    One more question, if I may - are there any examples using Reformer for question answering?
    Jérémie C. Wenger
    @jchwenger
    I'm also very interested in using the Reformer for text generation. What would be your advice for feeding in textual data which is longer than the example given in the Colab? So far I ran into errors trying to modify the architecture even slightly (to test the limit of the TPU memory), and went for the option of selecting a random slice of the same length as the original input, even dropping the padding mechanism entirely. Is it how you would do it on a large corpus?
    I'm also curious to know how easy it would be to train on several TPUs: would it work out of the box?
    Suraj Patil
    @patil-suraj
    @AlDante Hey, nice to that you are also interested in question answering. I am also trying to work out a demo with Reformer. Let me know if you come with anything. I will post the colab here if I finish it successfully.
    AlDante
    @AlDante
    @patil-suraj Hi Suraj, sure, it would be great to share experiences.
    Mahesh Bhole
    @mahesh21aug_twitter
    @AlDante, @patil-suraj I am also looking for QA for whole document rather than paragraph :)
    AlDante
    @AlDante
    @mahesh21aug_twitter Join the club :-)
    Jérémie C. Wenger
    @jchwenger
    I'd also like to add that the combination of LSH and reversible layers was mind-blowing, and bearing huge promise! Especially given the amount of work I've seen people doing in order to fit recent language models in memory.
    NGamma
    @NGamma
    def my_inputs(n_devices):
      while True:
        file = random.choice(os.listdir('files'))
        with GFile('/files/' + file) as f:
          text = f.read()
        IDS = TOKENIZER.EncodeAsIds(text)
    @nkitaev I'm using this to feed the multiple text files. Do you think I can tweak any of the hyparameters in the parse_config to run the model longer than half an hour without running into memory issues?
    Suraj Patil
    @patil-suraj
    @nikitakit @NGamma also how to batchify my_inputs ?
    Suraj Patil
    @patil-suraj
    Sorry, a better question is how to create batches for feeding the TPU, as in the original Reformer example each TPU core is running one example, so instead of that can we run batches of different examples
    nkitaev
    @nkitaev
    @patil-suraj In the example my_inputs returns 8 x 0.5M tensors, but you can change it to be 16x?, 32x?, etc.
    As long as the total batch size is a multiple of the number of devices (8), the code will work. Half a million tokens is close to the limit of what fits in 8GB, so if you increase the batch size you'll almost certainly need to shorten the length
    @NGamma The parameters of MultifactorSchedule control the learning rate schedule, which only affects how long training takes and not how much memory is used. You can try running with a little more warmup steps, and more steps_per_cycle in the cyclic cosine schedule.
    nkitaev
    @nkitaev
    Colabs do time out after a while, and I'm not sure how long of a training time you can reliably get without being preempted
    nkitaev
    @nkitaev
    @jchwenger Thanks! The 0.5M tokens in the demo is definitely at the limit of what fits in 8 GB. Past that you can chunk the data, get more memory (TPUv3 on Google cloud has 16GB per core instead of 8GB), or write custom code to split a single example across multiple TPU cores
    Suraj Patil
    @patil-suraj
    Hello, I'm running the colab Reformer notebook with a new dataset. I changed number of tokens to 281525. This is giving me following error
    TypeError: reshape total size must be unchanged, got new_sizes (1, 281525, 256) for shape (1, 512, 1024, 256).
    Any ideas, TYIA!
    nkitaev
    @nkitaev
    @patil-suraj I think the fix is to change ReformerLM.axial_pos_shape in the config. The product of all numbers in the tuple must be equal to the padded length
    Storing a position embedding vector for each of 0.5M positions is too wasteful, so the approach is to pretend that the text has 2D 512x1024 shape, and concatenate an "x-embedding" and a "y-embedding"
    @dimeldo You can try modifying the text generation demo. Redefining my_inputs will let you feed in your own data, and you can tune the model hyperparameters as well
    Suraj Patil
    @patil-suraj
    @nkitaev Yes, that seems to be the issue, I'm not aware how I should select shape for ReformerLM.axial_pos_shape. What will be the ReformerLM.axial_pos_shape for 281525
    nkitaev
    @nkitaev
    I think you'll need to pad it out to something that factors nicely
    Suraj Patil
    @patil-suraj
    I tried factoring it as shown in the colab, but as my vocab size is 16K, I ran into memory errors
    nkitaev
    @nkitaev
    Oh, vocab size 16K won't work with that length at the moment. We used to have support for this, but it got removed in a refactoring
    The problem is that output logits are size (281K, 16K), which is more than 8GB. They need to be chunked to fit in memory.
    This is on my agenda because I'm dealing with the exact same problem with MT (vocab size 32K)
    Suraj Patil
    @patil-suraj
    Aah, Thank you @nkitaev . Will have to try with smaller vocab then.
    Phil Wang
    @lucidrains
    @nkitaev hi, I'm curious but do you have any encouraging results for MT? I read in OpenReview that it is a work in progress
    Madison May
    @madisonmay
    @nkitaev curious whether there are plans to scale up the text Reformer model and release a pre-trained model a. la. BERT / RoBERTa, etc? Is the primary concern availability of appropriate corpora to train on where long-term context is useful in reducing an MLM loss?
    I'm dealing with a domain where I have a strong indicator that context more than 512 tokens away (long-form scanned documents) is useful and am interested in building off of the work of you and your collaborators.
    Lukasz Kaiser
    @lukaszkaiser
    @patil-suraj : to clarify the TF2 question: some lower-level things are quite hard to do in TF. One of them is really memory-efficient reversible layers, hashing is not trivial too. Trax in general can run with the TF2 backend (and, e.g., Trax Transformer runs using TF), but some things we needed in Reformer were just very hard to do without JAX. That's why we went with JAX and it's been working really well for us!