Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why LLaMA3-8B after GPTQ test in wikitext2 so bad? #650

Open
lyx-111111 opened this issue Apr 26, 2024 · 8 comments
Open

Why LLaMA3-8B after GPTQ test in wikitext2 so bad? #650

lyx-111111 opened this issue Apr 26, 2024 · 8 comments

Comments

@lyx-111111
Copy link

In Paper《How Good Are Low-bit Quantized LLAMA3 Models?An Empirical Study》,LLAMA3-8B after GPTQ ppl in wikitext2 should be 6.5,but I use AutoGPTQ the result is 17.5, who can tell me the difference or answer?

@Qubitium
Copy link
Contributor

Pass at least 128 examples of sufficient length to quantize()

@wenhuach21
Copy link

wenhuach21 commented Apr 28, 2024

In my opinion, using perplexity (ppl) as a metric might not be optimal due to its sensitivity to outliers, and a high perplexity score doesn't necessarily indicate poor model performance.

After thoroughly analyzing extensive datasets using various weight-only algorithms and assessing perplexities on datasets like Wikitext-2, PTB-new, and C4-new with GPTQ code and wiki ppl using LM-eval, we discovered that many algorithms, including floating models (though the probability is low), encounter this issue. We hypothesize that this issue stems from the mathematical calculation of perplexity (https://huggingface.co/docs/transformers/en/perplexity). For instance, even a low probability of a single token could significantly inflate the perplexity score.

@davidgxue
Copy link

#657
this maybe related

@lyx-111111
Copy link
Author

I change wikiText2 as calibration dataset, then the ppl is 6.62,which use c4 as calibration dataset is 17.5. Now the ppl can basically met expectations. I didn't realize before that the calibration dataset has such a significant impact on the quantization results. Do we need to quantifybased on the actual dataset every time we use GPTQ?

@Qubitium
Copy link
Contributor

Qubitium commented May 6, 2024

@lyx-111111 Wikitext2 is just a generic dataset and not guaranteed to work the best for all models. For best result, use a dataset that the model was pretrained on. Unfortunately dataset is often private/proprietary secret and thus lots of people use "wikitext2" as alternative. So yes, you need to use/find closest dataset for each model to get best calibration result.

@wenhuach21
Copy link

I change wikiText2 as calibration dataset, then the ppl is 6.62,which use c4 as calibration dataset is 17.5. Now the ppl can basically met expectations. I didn't realize before that the calibration dataset has such a significant impact on the quantization results. Do we need to quantifybased on the actual dataset every time we use GPTQ?

Hi, have you evaluated the models with the accuracy like mmlu, I suspect there won't be significant differences. Using the same dataset for both calibration and evaluation could lead to overfitting, resulting in poor generalization when applied to other tasks. We have already observed this issue with an 'SOTA' paper.

@Qubitium
Copy link
Contributor

Qubitium commented May 6, 2024

Using the same dataset for both calibration and evaluation could lead to overfitting, resulting in poor generalization when applied to other tasks. We have already observed this issue with an 'SOTA' paper.

@wenhuach21 Do you have a link to the SOTA paper? I really want to check it out. Also would a larger nsamples help with the overfittiing on quantization?

@wenhuach21
Copy link

Using the same dataset for both calibration and evaluation could lead to overfitting, resulting in poor generalization when applied to other tasks. We have already observed this issue with an 'SOTA' paper.

@wenhuach21 Do you have a link to the SOTA paper? I really want to check it out. Also would a larger nsamples help with the overfittiing on quantization?

I apologize for any confusion. What I meant is that some papers utilize WikiText for calibration and solely report WikiText perplexity, which may appear satisfactory but doesn't generalize effectively. Based on our data on llama2, increasing the sample size(128->512) could enhance average accuracy by an absolute 0.1-0.2 sometimes at W4G128, but this comes with about 1x tuning cost for GPTQ. And we do find that increase the samples size could have a big help occasionally in some other scenarios.

In this context, what I want to emphasize is that perplexity is highly sensitive to outliers. A large perplexity value may be caused by a low probability of a single token and might not necessarily indicate significant issues in real-world scenarios. We've observed this phenomenon across multiple quantization algorithms, where perplexity appears to be high on certain datasets, despite the accuracy remaining consistently good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants