XaaS Gemma 2 2B — Stage 2: QA Fine-Tuning

Stage 2 of 4 in the XaaS fine-tuning pipeline for Korean international trade.

Fine-tuned from the CPT-adapted model (lablup/gemma-2-2b-it-xaas-cpt) on 21,399 Korean trade QA pairs covering official 무역영어 1급 exam questions, trade terminology definitions, and lecture-derived QA. This model can answer questions about HS codes, Incoterms, customs law, letters of credit, and Korean trade regulations.

Pipeline Position

google/gemma-2-2b-it
    ↓
lablup/gemma-2-2b-it-xaas-cpt
    ↓  [this model]
lablup/gemma-2-2b-it-xaas-qa  ← you are here
    ↓
lablup/gemma-2-2b-it-xaas-kie  (KIE from B2B emails)
lablup/gemma-2-2b-it-xaas-sum-tag  (email summarization + tagging)

Training Details

Parameter Value
Base model lablup/gemma-2-2b-it-xaas-cpt
Method Supervised fine-tuning (SFT) with LoRA
LoRA rank (r) 128
LoRA alpha 32
LoRA dropout 0.05
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Epochs 4
Total steps 9,258
Learning rate 2e-4
Max sequence length 2,500 tokens
Batch size (effective) 8 (2 per device × 4 gradient accumulation)
Optimizer AdamW
Precision bfloat16
Framework HuggingFace TRL SFTTrainer

Training Data

lablup/tariff_trade_domain.synthetic_trade_qa_kr — 21,399 Korean trade QA pairs:

Source Rows Content
exam_mcq 1,430 Official 무역영어 1급 certification exam MCQs (KITA, 22 sessions)
term_qa 15,678 Trade terminology definition ↔ term QA
transcript_qa 4,291 LLM-generated QA from Korean trade lecture transcripts

How to Use

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "lablup/gemma-2-2b-it-xaas-qa"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

def ask(question: str, context: str = "") -> str:
    content = f"Context: {context}\n\nQuestion: {question}" if context else question
    messages = [{"role": "user", "content": content}]
    prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    with torch.no_grad():
        outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
    return tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)

# Trade terminology
print(ask("Incoterms FOB 조건에서 위험 이전 시점은 언제인가요?"))

# Exam-style MCQ
print(ask(
    "다음 중 신용장(L/C) 거래에서 개설은행의 의무로 옳은 것은?",
    context="1. 수익자가 제출한 서류가 신용장 조건에 일치하면 대금을 지급할 의무가 있다. "
            "2. 수익자의 선적 여부와 관계없이 대금을 지급해야 한다. ..."
))

Use as instruction fine-tuning format:

def format_prompt(context: str, question: str) -> str:
    return f"Context: {context}\n\nQuestion: {question}\n\nAnswer:"

Evaluation

Trained on the train split of lablup/tariff_trade_domain.synthetic_trade_qa_kr. No held-out test set was used during training. Use train_test_split() on the dataset for evaluation.

Downstream Models

Model Task
lablup/gemma-2-2b-it-xaas-kie B2B email key-information extraction → YAML
lablup/gemma-2-2b-it-xaas-sum-tag Email summarization + topic tagging

Limitations

  • QA pairs are LLM-generated (term_qa, transcript_qa) or from historical exams (exam_mcq); answers may not reflect current regulatory changes
  • Knowledge cutoff reflects google/gemma-2-2b-it base + training data generation date (~2024)
  • Model has not been evaluated on external Korean trade benchmarks

License

Built on Google Gemma 2 and subject to the Gemma Terms of Use.

Downloads last month
16
Safetensors
Model size
3B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for lablup/gemma-2-2b-it-xaas-qa

Adapter
(1)
this model
Adapters
1 model
Finetunes
1 model

Collection including lablup/gemma-2-2b-it-xaas-qa