Views
No views yet

pip install zebra-qa1git clone https://github.com/sapienzanlp/zebra.git
2cd zebra
3conda create -n zebra python==3.10
4conda activate zebra
5pip install -e .1from zebra import Zebra
2
3# Load Zebra with language model, retriever, document index and explanations.
4zebra = Zebra(
5 model="meta-llama/Meta-Llama-3-8B-Instruct",
6 retriever="sapienzanlp/zebra-retriever-e5-base-v2",
7 document_index="sapienzanlp/zebra-kb"
8)
9
10# Provide a question and answer choices.
11questions = [
12 "What should you do if you see someone hurt and in need of help?",
13 "If your friend is upset, what is the best way to support them?",
14 "What should you do if your phone battery is running low in a public place?",
15 "What should you do if you are running late for an important meeting?",
16]
17
18choices = [
19 ["Walk away.", "Call for help.", "Take a photo for social media."],
20 ["Listen to them and offer comfort.", "Tell them they are overreacting.", "Ignore them and walk away."],
21 ["Borrow a stranger's phone.", "Use public charging station.", "Leave your phone unattended while it charges."],
22 ["Rush through traffic.", "Call and inform them you will be late.", "Do not show up at all."],
23]
24
25# Generate knowledge and perform question answering.
26zebra_output = zebra.pipeline(questions=questions, choices=choices)1 ZebraOutput(
2 explanations=[
3 [
4 "Walking away would be neglecting the person's need for help and potentially putting them in danger.",
5 'Calling for help, such as 911, is the most effective way to get the person the assistance they need.',
6 "Taking a photo for social media might spread awareness, but it's not a direct way to help the person in need."
7 ],
8 [
9 'Listening and offering comfort shows empathy and understanding.',
10 "Telling someone they're overreacting can be dismissive and unhelpful.",
11 'Ignoring someone in distress can be hurtful and unkind.'
12 ],
13 [
14 "Borrow a stranger's phone: Unwise, as it's a security risk and may lead to theft or damage.",
15 "Use public charging station: Safe and convenient, as it's a designated charging area.",
16 'Leave your phone unattended while it charges: Not recommended, as it may be stolen or damaged.'
17 ],
18 [
19 'Rush through traffic: This option is risky and may lead to accidents or stress.',
20 'Call and inform them you will be late: This is the most likely option, as it shows respect for the meeting and allows for adjustments.',
21 'Do not show up at all: This is unacceptable, as it shows disrespect for the meeting and may damage relationships.'
22 ],
23 ],
24 answers=[
25 "Call for help.",
26 "Listen to them and offer comfort.",
27 "Use public charging station.",
28 "Call and inform them you will be late."
29 ],
30 )zebra.pipeline method with the return_dict parameter set to True to ask ZEBRA to return also the retrieved examples along with their explanations.| Model | CSQA | ARC-C | ARC-E | OBQA | PIQA | QASC | CSQA2 | WG | AVG |
|---|---|---|---|---|---|---|---|---|---|
| Mistral-7B-Instruct-v0.2 | 68.2 / 73.3 | 72.4 / 75.2 | 85.8 / 87.4 | 68.8 / 75.8 | 76.1 / 80.2 | 66.1 / 68.3 | 58.5 / 67.5 | 55.8 / 60.7 | 68.9 / 73.5 |
| Phi3-small-8k-Instruct | 77.2 / 80.9 | 90.4 / 91.6 | 96.9 / 97.7 | 90.4 / 91.2 | 86.6 / 88.1 | 83.5 / 81.0 | 68.0 / 74.6 | 79.1 / 81.0 | 84.0 / 85.8 |
| Meta-Llama-3-8b-Instruct | 73.9 / 78.7 | 79.4 / 83.5 | 91.7 / 92.9 | 73.4 / 79.6 | 78.3 / 84.0 | 78.2 / 79.1 | 64.3 / 69.4 | 56.2 / 63.2 | 74.4 / 78.8 |
| Phi3-mini-128k-Instruct | 73.4 / 74.8 | 85.7 / 88.0 | 95.4 / 96.0 | 82.8 / 87.8 | 80.4 / 84.2 | 74.7 / 73.9 | 59.3 / 64.6 | 67.3 / 72.9 | 77.4 / 80.5 |
1@inproceedings{molfese-etal-2024-zebra,
2 title = "{ZEBRA}: Zero-Shot Example-Based Retrieval Augmentation for Commonsense Question Answering",
3 author = "Molfese, Francesco Maria and
4 Conia, Simone and
5 Orlando, Riccardo and
6 Navigli, Roberto",
7 editor = "Al-Onaizan, Yaser and
8 Bansal, Mohit and
9 Chen, Yun-Nung",
10 booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
11 month = nov,
12 year = "2024",
13 address = "Miami, Florida, USA",
14 publisher = "Association for Computational Linguistics",
15 url = "https://aclanthology.org/2024.emnlp-main.1251",
16 doi = "10.18653/v1/2024.emnlp-main.1251",
17 pages = "22429--22444"
18}