atlas

Research map / Large language models / Retrieval and knowledge

Code-Style In-Context Learning for Knowledge-Based Question Answering

AAAI 2024 · Large language models › Retrieval and knowledge · approach: Knowledge graph reasoning with LLMs · 17 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes KB-Coder, a training-free KBQA method that reformulates S-Expression logical form generation as Python meta-function call generation under code-style in-context learning with GPT-3.5-turbo, plus a retrieved related relation hint for zero-shot generalization.

Problem

LLMs rarely see logical forms in pre-training, so in-context semantic parsing for KBQA suffers high format error rates, and zero-shot generalization to unseen schema items is poor.

Approach

Define seven Python meta-functions implementing S-Expression operations and prompt the LLM to generate step-by-step function call sequences (code) from few-shot demos; additionally insert one retrieved KB relation most similar to the question as a hint, and link entities/relations via SimCSE+Faiss with candidate enumeration.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use code-style function-call generation instead of directly generating logical formsKB-Coder vs KB-BINDER · WebQSP (100-shot)F1: 52.6(1.1) -> 55.7(1.3)Helped
Use code-style function-call generation instead of directly generating logical formsKB-Coder vs KB-BINDER · GraphQ (100-shot)FER: 15.4(1.6) -> 6.3(2.5)Helped
Provide one question-related relation as a referenceKB-Coder · GrailQA zero-shotF1Helped
Provide one question-related relation as a reference (ablation)KB-Coder · GrailQA I.I.D and compositionalF1No clear effect
Add instruction definitions for the meta-functions (ablation)KB-Coder · GrailQAF1Helped
Add instruction definitions for the meta-functions (ablation)KB-Coder · GrailQAFERHelped
Include demonstration examples (ablation)KB-Coder · GrailQAF1Helped
Increase the number of related relations beyond oneKB-Coder · GrailQA subsetF1Hurt
Increase the number of demo examplesKB-Coder · GrailQA subsetF1Helped
Increase the number of answers participating in majority voteKB-Coder · GrailQA subsetFERHelped
Select the highest-F1 candidate instead of the first candidate with a non-empty queryKB-Coder (6)-R · GraphQF1: 36.6 to 50.2Helped

Surprising findings

Limitations

Experimental setup

Datasets: WebQSP GrailQA GraphQ

Benchmarks: WebQSP GrailQA GraphQ

Metrics: F1 EM format error rate

Baselines: KB-BINDER RnG-KBQA DecAF TIARA ArcaneQA SPARQA BERT + Ranking

Builds on: KB-BINDER S-Expression SimCSE Faiss

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy