--- base_model: google/gemma-3-12b-it library_name: peft pipeline_tag: text-generation language: - en tags: - peft - lora - data-to-text - text-to-data - factual-consistency - hallucination-detection --- # XQDT E2E verifier: gemma3 12B This repository contains the LoRA adapter for the **gemma3 12B** XQDT verifier from *XQDT: eXplainable and Quantitative Data-Text Alignment Metric with Feedback Signals*. It is used with [`google/gemma-3-12b-it`](https://huggingface.co/google/gemma-3-12b-it). This E2E checkpoint was trained on the joint WebNLG--E2E synthetic training set. ## Overview XQDT verifies alignment between English text and structured triples. It returns `missing`, `extra`, and `incorrect` units, or `All correct`. `missing` identifies an input unit omitted from the text, `extra` identifies text content unsupported by the input, and `incorrect` identifies an input unit realised with incorrect information. Example inputs and outputs are provided in `smoke_test.json`. Generated text may vary slightly across inference libraries and package versions. ## Prompt format ```text Verify if the triples align with the text. Find missing, extra, or incorrect triples. TEXT: {text} TRIPLES: 1. [S] {subject} [P] {predicate} [O] {object} Output as markdown table with Type and Triple columns. ``` ## ms-swift ```python import torch from swift.infer_engine import InferRequest, RequestConfig, TransformersEngine BASE_MODEL = "google/gemma-3-12b-it" ADAPTER_ID = "Loria-MosAIk/xqdt-e2e-gemma3-12b" SYSTEM_PROMPT = "Identify extra, missing and incorrect triples precisely." QUERY = """Verify if the triples align with the text. Find missing, extra, or incorrect triples. TEXT: Blue Spice is a coffee shop in city centre. TRIPLES: 1. [S] Blue Spice [P] area [O] city centre 2. [S] Blue Spice [P] eat type [O] coffee shop Output as markdown table with Type and Triple columns.""" MESSAGES = [{"role": "user", "content": QUERY}] engine = TransformersEngine( BASE_MODEL, adapters=[ADAPTER_ID], max_batch_size=1, torch_dtype=torch.bfloat16, device_map="auto", template_type="gemma3_text", use_hf=True, ) response = engine.infer( [InferRequest(messages=MESSAGES)], RequestConfig(max_tokens=1024, temperature=0.3, seed=2023), use_tqdm=False, )[0] print(response.choices[0].message.content) ``` ## Transformers and PEFT ```python import torch from peft import PeftModel from transformers import set_seed BASE_MODEL = "google/gemma-3-12b-it" ADAPTER_ID = "Loria-MosAIk/xqdt-e2e-gemma3-12b" SYSTEM_PROMPT = "Identify extra, missing and incorrect triples precisely." QUERY = """Verify if the triples align with the text. Find missing, extra, or incorrect triples. TEXT: Blue Spice is a coffee shop in city centre. TRIPLES: 1. [S] Blue Spice [P] area [O] city centre 2. [S] Blue Spice [P] eat type [O] coffee shop Output as markdown table with Type and Triple columns.""" MESSAGES = [{"role": "user", "content": QUERY}] set_seed(2023) from transformers import AutoProcessor, Gemma3ForConditionalGeneration processor = AutoProcessor.from_pretrained(BASE_MODEL) base = Gemma3ForConditionalGeneration.from_pretrained( BASE_MODEL, torch_dtype=torch.bfloat16, device_map="auto" ) model = PeftModel.from_pretrained(base, ADAPTER_ID).eval() prompt = processor.apply_chat_template(MESSAGES, tokenize=False, add_generation_prompt=True) inputs = processor(text=prompt, return_tensors="pt").to(model.device) with torch.inference_mode(): output = model.generate(**inputs, max_new_tokens=1024, do_sample=True, temperature=0.3) generated = output[0, inputs["input_ids"].shape[-1]:] print(processor.decode(generated, skip_special_tokens=True)) ``` ## vLLM ```python from huggingface_hub import snapshot_download from vllm import LLM, SamplingParams from vllm.lora.request import LoRARequest BASE_MODEL = "google/gemma-3-12b-it" ADAPTER_ID = "Loria-MosAIk/xqdt-e2e-gemma3-12b" SYSTEM_PROMPT = "Identify extra, missing and incorrect triples precisely." QUERY = """Verify if the triples align with the text. Find missing, extra, or incorrect triples. TEXT: Blue Spice is a coffee shop in city centre. TRIPLES: 1. [S] Blue Spice [P] area [O] city centre 2. [S] Blue Spice [P] eat type [O] coffee shop Output as markdown table with Type and Triple columns.""" MESSAGES = [{"role": "user", "content": QUERY}] adapter_path = snapshot_download(ADAPTER_ID) llm = LLM(model=BASE_MODEL, enable_lora=True) outputs = llm.chat( MESSAGES, SamplingParams(max_tokens=1024, temperature=0.3, seed=2023), lora_request=LoRARequest("xqdt", 1, adapter_path), ) print(outputs[0].outputs[0].text) ``` ## Citation ```bibtex @inproceedings{efimov-zhang-etal-2026-xqdt, title = {XQDT: eXplainable and Quantitative Data-Text Alignment Metric with Feedback Signals}, author = {Efimov-Zhang, Kun and Song, Yifei and Gardent, Claire}, booktitle = {Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing}, year = {2026} } ```