Instructions to use lablup/gemma-2-2b-it-xaas-qa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lablup/gemma-2-2b-it-xaas-qa with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lablup/gemma-2-2b-it-xaas-qa") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lablup/gemma-2-2b-it-xaas-qa") model = AutoModelForCausalLM.from_pretrained("lablup/gemma-2-2b-it-xaas-qa") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use lablup/gemma-2-2b-it-xaas-qa with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use lablup/gemma-2-2b-it-xaas-qa with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lablup/gemma-2-2b-it-xaas-qa" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablup/gemma-2-2b-it-xaas-qa", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lablup/gemma-2-2b-it-xaas-qa
- SGLang
How to use lablup/gemma-2-2b-it-xaas-qa with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lablup/gemma-2-2b-it-xaas-qa" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablup/gemma-2-2b-it-xaas-qa", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lablup/gemma-2-2b-it-xaas-qa" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablup/gemma-2-2b-it-xaas-qa", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lablup/gemma-2-2b-it-xaas-qa with Docker Model Runner:
docker model run hf.co/lablup/gemma-2-2b-it-xaas-qa
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-itbase + 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