                        FACT T EST: Factuality Testing in Large Language Models with Statistical Guarantees

                                          FactTest-t         R-Tuning     Finetune All              Finetune Half        Pretrained
                              100
                                                       OpenLLaMA-3b                                           LLaMA-7b
                               75


                   Accuracy
                               50
                               25
                                    ParaRel       HotpotQA      WiCE    FEVER             ParaRel       HotpotQA    WiCE          FEVER

Figure 3: The Accuracy performance (%) of FACT T EST trained on half of the data, comparing with training-based baselines.
Both R-Tuning and Finetune All utilize all training data for finetuning, while Finetune Half uses the same half of the
finetuning data as FACT T EST.




                                    (a)                                                  (b)                                           (c)

Figure 4: (a) The Accuracy performance (%) of FACT T EST on ParaRel-OOD testing dataset. (b)(c) FACT T EST O maintains
its ability to control Type I error given a significance level α when distribution shifts exist.

FACT T EST-t yields 34% and 28% accuracy improvement                                Table 3: The accuracy performance (%) of FACT T EST ap-
over R-Tuning on HotpotQA and FEVER, respectively. De-                              plied to GPT-4o-mini. The significance level is chosen as
spite the reduced size of the calibration dataset, FACT T EST-t                     5%. The number in parentheses is Type I error. GPT +
maintains effective control over Type I error, with further                         7B/13B means utilizing OpenLLaMA-7B/13B to calculate
details provided in Appendix D.4.                                                   certainty scores for GPT-4o mini.
                                                                                      Dataset            Model      FT EST-se10       FT EST-se15    FT EST-kle15
5.4. Extension to Covariate Shifts                                                                   GPT-4o mini                         52.83
                                                                                     ParaRel          GPT + 7B      77.78 (0.03)      77.31 (0.03)   83.88 (0.05)
In this subsection, we evaluate the extension of our frame-
                                                                                                     GPT + 13B      76.91 (0.04)      77.67 (0.05)   85.84 (0.04)
work, denoted as FACT T EST O (FACT T EST for Out-of-
                                                                                                     GPT-4o mini                         75.67
distribution domains), on dataset with distribution shifts.                              WiCE         GPT + 7B      81.82 (0.02)      76.67 (0.03)        –
                                                                                                     GPT + 13B      86.95 (0.01)      81.77 (0.02)        –
Setup. We utilize ParaRel for training, consistent with the
aforementioned experiments. We randomly split ParaRel-
OOD into a validation dataset comprising 1,000 samples and
a testing dataset containing 12k samples. To calculate the                          out fine-tuning. Additionally, FACT T EST O effectively en-
density ratio in Section 3 between the target distribution and                      forces the upper bound on the Type I error, thereby main-
the source distribution, we employ the training data from                           taining its efficacy in out-of-distribution scenarios.
the source domain and the validation data from the target
domain to train a binary classifier and utilize the predicted                       5.5. Extension to Black-box APIs
probability to approximate density ratios. Subsequently, we                         We further evaluate our framework on black-box models to
select B as the γ upper quantile of density ratios to filter out                    broaden the applicability of our framework. While score
anomalous values. We set the default value of γ as 90%.                             functions like SE and KLE require token probabilities,
Experimental Results. Figure 4 depicts the performance                              which are unavailable for black-box APIs, we utilize open-
of FACT T EST O on the ParaRel-OOD testing dataset, along-                          source models to calculate the scores on calibration datasets
side the Type I error-α curve. The results demonstrate that                         constructed by black-box models. Table 3 illustrates the
FACT T EST O-t significantly outperforms baseline methods                           performance of FACT T EST on GPT-4o Mini. The results
by a large margin. Notably, when utilizing OpenLLaMA-                               demonstrate that the scores derived from open-source mod-
3B as the pretrained model, both FACT T EST O-se and                                els are effective for black-box APIs, achieving a 33% accu-
FACT T EST O-kle outperform training-based methods with-                            racy improvement on ParaRel and an 11% improvement on
                                                                                    WiCE, while maintaining control over Type I error. These

                                                                                8
