Ask HN: Explain how size of input changes ChatGPT performance
In a hypothetical where I can run my inputs directly on good hardware how should I be thinking of performance of these models in relation to my input / output size?
And what's happening under the hood in the model's architecture? It seems to return 1 token at a time? Does that mean it predicts one token at a time, adds that to the context window, and then does another forward inference pass?
If I tune a model to respond with simple `0` or `1` answers to yes and no questions will that be faster than letting it answer "yes {reason}" or "no {reason}"? If it were inferring single tokens it seems like that would always be faster, but if it were inferring a block of tokens maybe not...?
I'll summarize everything shared here into a blog post for the next person who asks :) Thanks.
3 comments
[ 4.7 ms ] story [ 19.1 ms ] threadAs for model performance at different context sizes, it's seems a bit complicated. From what I understand, even if models are tweaked (for example using the superHOT RoPE hack or sparse attention) to be able to use longer contexts, they still have to be fined tuned on input of this increased context to actually utilize it, but performance seems to degrade regardless as input length increases.
For your question about fine tuning models to respond with only "yes" or "no", I recommend looking into how the jsonformers library works: https://github.com/1rgs/jsonformer . Essentially, you still let the model generate many tokens for the next position, and only accept the ones that satisfy certain criteria (such as the token for "yes" and the token for "no".
You can do this with openAI API too, using tiktoken https://twitter.com/AAAzzam/status/1669753722828730378?t=d_W... . Be careful though as results will be different on different selections of tokens, as "YES", "Yes", "yes", etc are all different tokens to the best of my knowledge
Ok then -- so these forward passes should take about the same amount of time per inference of the next token. That matches my intuition. When does the model know to stop? Is there a stop token?
Also aside -- totally crazy this thing can run a full forward-pass many times a second. I naively would have bet each pass token a lot longer even on powerful GPUs
Basically during pre-training/fine-tuning, for every sequence you'd like your model to generate (for example a multi-turn chat instruct model like chatGPT), you have a flag at the end of the expected output (like end of string, <|something like this|>, or some random hash to prevent users from doing weird "sql-injection style" prompt hacking (ex: https://twitter.com/nostalgebraist/status/168657604180309606...)
Then, during inference, if the model generates the special flag, it terminates the function and the string is returned.
Also on your note about multiple passes a second, it's absolutely wild how much compute modern computers have. My 3090 goes on full blast during inference on 13B llama models. To think that GPT 3.5 is 10 times the size of that https://en.wikipedia.org/wiki/GPT-3, and that GPT 4 is 10 times the size of THAT https://www.semianalysis.com/p/gpt-4-architecture-infrastruc...