Views
No views yet

32K tokens. Depending on use cases, adjusting chunk size may yield better performance.Llama-3.1-Bespoke-MiniCheck-7B is finetuned from internlm/internlm2_5-7b-chat (Cai et al., 2024)
on the combination of 35K data points only:meta-llama/Meta-Llama-3.1-405B-Instruct, thus the name Llama-3.1-Bespoke-MiniCheck-7B.
pip install "minicheck[llm] @ git+https://github.com/Liyan06/MiniCheck.git@main"1from minicheck.minicheck import MiniCheck
2import os
3os.environ["CUDA_VISIBLE_DEVICES"] = "0"
4
5doc = "A group of students gather in the school library to study for their upcoming final exams."
6claim_1 = "The students are preparing for an examination."
7claim_2 = "The students are on vacation."
8
9# model_name can be one of:
10# ['roberta-large', 'deberta-v3-large', 'flan-t5-large', 'Bespoke-MiniCheck-7B']
11scorer = MiniCheck(model_name='Bespoke-MiniCheck-7B', enable_prefix_caching=False, cache_dir='./ckpts')
12pred_label, raw_prob, _, _ = scorer.score(docs=[doc, doc], claims=[claim_1, claim_2]) # can set `chunk_size=your-specified-value` here, default to 32K chunk size.
13
14print(pred_label) # [1, 0]
15print(raw_prob) # [0.9840446675150499, 0.010986349594852094]Automatic Prefix Caching (APC in short) caches the KV cache of existing queries, so that a new query can directly reuse the KV cache if it shares the same prefix with one of the existing queries, allowing the new query to skip the computation of the shared part.
Bespoke-MiniCheck-7B, simply set enable_prefix_caching=True when initializing the
MiniCheck model (no other changes are needed):scorer = MiniCheck(model_name='Bespoke-MiniCheck-7B', enable_prefix_caching=True, cache_dir='./ckpts')1import pandas as pd
2from datasets import load_dataset
3from minicheck.minicheck import MiniCheck
4import os
5os.environ["CUDA_VISIBLE_DEVICES"] = "0"
6
7# load 29K test data
8df = pd.DataFrame(load_dataset("lytang/LLM-AggreFact")['test'])
9docs = df.doc.values
10claims = df.claim.values
11
12scorer = MiniCheck(model_name='Bespoke-MiniCheck-7B', enable_prefix_caching=False, cache_dir='./ckpts')
13pred_label, raw_prob, _, _ = scorer.score(docs=docs, claims=claims) # ~ 500 docs/min, depending on hardware1from sklearn.metrics import balanced_accuracy_score
2
3df['preds'] = pred_label
4result_df = pd.DataFrame(columns=['Dataset', 'BAcc'])
5for dataset in df.dataset.unique():
6 sub_df = df[df.dataset == dataset]
7 bacc = balanced_accuracy_score(sub_df.label, sub_df.preds) * 100
8 result_df.loc[len(result_df)] = [dataset, bacc]
9
10result_df.loc[len(result_df)] = ['Average', result_df.BAcc.mean()]
11result_df.round(1)@InProceedings{tang-etal-2024-minicheck,
title = {MiniCheck: Efficient Fact-Checking of LLMs on Grounding Documents},
author = {Liyan Tang and Philippe Laban and Greg Durrett},
booktitle = {Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing},
year = {2024},
publisher = {Association for Computational Linguistics},
url = {https://arxiv.org/pdf/2404.10774}
}
@misc{tang2024bespokeminicheck,
title={Bespoke-Minicheck-7B},
author={Bespoke Labs},
year={2024},
url={https://huggingface.co/bespokelabs/Bespoke-MiniCheck-7B},
}