Live data from Hacker News

Exponentially faster language modelling

arxiv.org

121–130 of 150 posts

Re: Exponentially faster language modelling

#121
post #46

Earlier quoted context omitted.

> This model is provided only as sanity check for research purposes, it is untested and unfit for deployment. I guess this means it isn't pretrained yet? Is it still just random weights?

"Unfit for deployment" or "not intended for deployment" is semi-standard wording for research models that are just raw language models with none of the safety/bias/offensiveness filtering that is usually desired for product applications. For example, if you deploy it as a customer-service chatbot, it might tell your customers to kill themselves, or call them racial slurs. It doesn't mean that there's anything technic…

Is it even fine tuned for question answering?

Re: Exponentially faster language modelling

#122
For those not familiar with Bert transformer arch. You can read a bunch of their torch benchmark code to measure speed up in just the FFF: https://github.com/pbelcak/UltraFastBERT/blob/main/benchmark...

some of which is from the pytorch docs here: https://pytorch.org/tutorials/intermediate/torch_compile_tut..., e.g. the `timed` function and how they generate data.

Also its not just the same 12 neurons, its the 12 neurons based on the previous dot product. So some kind of JIT is needed to load the right ones?

Re: Exponentially faster language modelling

#123

Earlier quoted context omitted.

From the previous paper you cited >Pushing FFFs to the limit, we show that they can use as little as 1% of layer neurons for inference in vision transformers while preserving 94.2% of predictive performance. This feels like that often misinterpreted Einstein meme/qoute about humans only using a fraction of their brain power. Is this only for inference though? could it boost training?

That's an interesting question. It actually provides a nice way to parallelized training: Pretrain e.g. the first 3 branch levels, which effectively fragments the model into 8 separate parts, which you can continue training across 8 independent servers/nodes with no further communication between the nodes. A central server would run the 1st 3 levels and mark parts of the training set that each node has to train on. M…

You should check out Hivemind[1]. It is very similar to what you described except it used MoE for "fragmentation". They have a couple of examples of pre-training in their repo. Hivemind was also used to build Petals[2] but it only supports fine-tuning and inference[3] afaik.

[1] https://github.com/learning-at-home/hivemind [2] https://github.com/bigscience-workshop/petals [3] https://chat.petals.dev/

Re: Exponentially faster language modelling

#125
post #102

hugging face model https://huggingface.co/pbelcak/UltraFastBERT-1x11-long

Is it possible to use this with something like Llama 2?

This requires retraining from scratch, so no, you can't use Llama 2 pretrained weight.

As far as I can tell you can take Llama 2 modelling code, training infrastructure, training data and apply proposed modification (they provide PyTorch nn.Module which should be drop in replacement of nn.Linear) and run the training if you have enough compute and it should work. Doesn't mean it would work, there are always lots of practical problems, but it should work in principle.

Re: Exponentially faster language modelling

#126
Another noob Question: So a 50% size reduction in BERT? let's see if I am getting these numbers right. At inference time you need a fraction of the neurons in the FF layer to do the inference based on the input data and the previous dot product. Here some quick math for BERT-Base which has 110M params according to the original paper:

----

    L (Number of Layers): 12 transformer blocks.

    H (Hidden Size): 768 units in the hidden layers.
  
    A (Number of Attention Heads): 12 attention heads.
Embedding Layers:

     WordPiece Embeddings: 768 (hidden size) * 30,522 (vocab size) = 23,440,896 parameters.
        
     Positional Embeddings: 768 * 512 (max sequence length) = 393,216 parameters.
     
     Segment Embeddings: 768 * 2 (number of segments) = 1,536 parameters.
  
     Total Embedding Parameters: 23,440,896 + 393,216 + 1,536 = 23,835,648 parameters.
Transformer Blocks:

   Each transformer block has the following components:
   
       Self-Attention Layer: Each attention head has 768 / 12 = 64 units.
  
            Query (Q), Key (K), Value (V) matrices: 3 * (64 * 768) = 147,456 parameters per head.
 
            Across 12 heads: 147,456 * 12 = 1,769,472 parameters.

            Output layer of the attention mechanism: 768 * 768 = 589,824 parameters.
       
      Feed-Forward Network (FFN):
      
         First layer: 768 (input) * 3,072 (intermediate size) = 2,359,296 parameters.
   
         Second layer: 3,072 * 768 = 2,359,296 parameters.

            Total FFN parameters per block: 2,359,296 + 2,359,296 = 4,718,592 parameters. -----------------> *This is the number to keep in mind.*
        
     Total Parameters per Block: 1,769,472 (self-attention) + 589,824 (output) + 4,718,592 (FFN) = 7,077,888 parameters.
        
     Total for 12 Blocks: 7,077,888 * 12 = 84,934,656 parameters.

    Layer Norm and Other Parameters:
        
        Each transformer block also includes layer normalization and other small components, which add a relatively small number of parameters.

Total Parameters:

        Embeddings: 23,835,648

        Transformer Blocks: 84,934,656

        Layer Norm and Others: A small number, completing the total to around 110 million.
--------------------------------------

4.718M FF Params per block * 12 ~ 56.6 Million/110M Params which is a staggering ~50% reduction in size at inference time if you use 0.3% of the FF neurons for FFF??

Re: Exponentially faster language modelling

#127

Earlier quoted context omitted.

A lot of CPU inference libraries (llama.cpp included) use as much SIMD as possible, sometimes by hand-writing loops. The one I hack on, llama.rs, uses portable_simd but specializes to your CPU at compile time. My experience has been that most CPU inference is actually not compute limited, but memory bandwidth limited, since most weights are used for a few operations per token (how quickly can you load and unload the…

Would you say that is the state of the art CPU inference library?

ggml.cpp with blast backend could be one example of it See for instance: https://github.com/ggerganov/ggml/blob/57c468b8655f3630d1749... which are the parts not available in blast

Re: Exponentially faster language modelling

#128

Link to previous paper: https://arxiv.org/abs/2308.14711 An attempt at a summary: They use a sigmoid function to make differentiable "soft" branches, and stack them to construct a binary tree, with the goal of only taking one branch at inference time (but training the whole tree) leading to log(W) instead of W inference cost. They gradually harden the branches so they become hard branches at the end of training. A br…

From the previous paper you cited >Pushing FFFs to the limit, we show that they can use as little as 1% of layer neurons for inference in vision transformers while preserving 94.2% of predictive performance. This feels like that often misinterpreted Einstein meme/qoute about humans only using a fraction of their brain power. Is this only for inference though? could it boost training?

Why not have a GitHub or hug face demo instead of saying it’s the best thing since slice bread?

Re: Exponentially faster language modelling

#129
post #110

Earlier quoted context omitted.

Even like OpenChat-3.5? (Probably the best 7B model out there) Demo: https://openchat.team/ HuggingFace: https://huggingface.co/openchat/openchat_3.5 On the LLM arena (blinded comparisons), it's the third best non-proprietary model: https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboar...

What is the sum of odd numbers in this set: 4, 7, 12, 1, 3 The sum of odd numbers in the given set is 4 + 7 + 1 = 12. Therefore, the answer is 12.

is this really what you are using AI for ?

Re: Exponentially faster language modelling

#130
post #107

Earlier quoted context omitted.

I wouldn't be so quick to conspiracy. I'm the author of a work and a famous blog post that trains a particular common architecture much faster (don't want to dox myself too much) and with far fewer parameters, but it has been rejected several times and is now arxiv only. Our most common complaint was "who would use this? Why not just take a large model and tune it?" That question alone held us back a year (had over a…

Is there a place where you guys discuss... things? I'm layman interested in this topic akin to pop-physics/maths, but have no chance to just read papers and "get it". On the other hand, immediately available resources focus more on how-to part of it rather than on what's up overall. Also, do you have something like 3b1b/pbs/nph for it? Content that you can watch and say "well, yep, good job".

I don't have any great recommendations and unfortunately my advice may be not what you want to hear. What I tell my students is "You don't need to know math to build good models, but you need to know math to know why your models are wrong." But this is even a contentious statement within the community. (Personally I'm more interested in exploring what we can build and understand rather than focusing on throwing more compute and data at problems. There's a lot of work to be done that does not require significant compute, but it isn't flashy and you'll get little fame. Every famous model you know has some unsung hero(s) who built the foundation before compute was thrown at the problem). I was previously a physicist and we similarly frequently express that you do not know the material unless you can do the math. Physicists are trained in generating analogies as they help communication but this sometimes leads to people convincing themselves that they understand things far more than they actually do. They say the devil is in the details, and boy are there a lot of details. (Of the science communicators, I'm happy those are the ones you mention though!) But do not take this as gatekeeping! These groups are often happy to help with the math and recommend readings. ML is kinda a while west and you can honestly pick a subdomain of math and probably find it useful, but I would start by making sure you have a foundation in multivariate calculus and linear algebra.

As to paper reading, my suggestion is to just start. This is a fear I faced when I began grad school and it feels overwhelming and like everyone is leagues ahead of you and you have no idea where to begin. I promise that is not the case. Start anywhere, it is okay, as where you end up will not matter too much on where you begin. Mentors help, but they aren't necessary if you have dedication. As you read you will become accustomed to the language and start to understand the "lore." I highly suggest following topics you find interesting backwards through time, as this has been one of the most beneficial practices in my learning. I still find revisiting some old works reveals many hidden gems that were forgotten. Plus, they'll be easier to read! Yes, you will have to reread many of those works later, as you mature your knowledge, but that is not a bad thing. You will come with newer eyes. Your goal should be to first understand the motivation/lore, so do not worry if you do not understand all the details. You will learn a lot through immersion. It is perfectly okay if you barely understand a work when first starting because a mistake many people make (including a lot of researchers!) is that a paper is not and cannot be self contained. You cannot truthfully read a work without understanding its history and that only comes with time and experience. Never forget this aspect; it is all too easy to deceive yourself that things are simpler than they are (the curse of hindsight).

I'd also suggest to just get building. To learn physics you must do physics problems. To learn ML you must build ML systems. There are no shortcuts but progress is faster than it looks. There's hundreds of tutorials out there and most are absolute garbage but I also don't have something I can point to that's comprehensive. Just keep in mind that you're always learning and so are the people writing tutorials. I'm going to kinda just dump some links, they aren't in any particular order sorry haha. Its far from comprehensive, but this should help you getting started, nothing in here is too advanced. If it looks complicated, spend more time, you'll get it. It's normal if it doesn't click right away and there's nothing wrong with that.

https://www.youtube.com/@Mutual_Information

https://www.youtube.com/@EmergentGarden

https://www.youtube.com/@pascalpoupart3507

https://www.youtube.com/@AndrejKarpathy

https://www.youtube.com/@alfcnz

https://www.youtube.com/@rmcelreath

http://neuralnetworksanddeeplearning.com/

https://adversarial-ml-tutorial.org/introduction/

https://www.deeplearningbook.org/

https://nlp.seas.harvard.edu/2018/04/03/attention.html

https://huggingface.co/blog/annotated-diffusion

https://lilianweng.github.io

https://pytorch.org/ecosystem/

https://medium.com/pytorch/archive

https://www.inference.vc/

Post reply on HN