Instructions to use lablup/gemma-2-2b-it-xaas-kie 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-kie 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-kie") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lablup/gemma-2-2b-it-xaas-kie") model = AutoModelForCausalLM.from_pretrained("lablup/gemma-2-2b-it-xaas-kie", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lablup/gemma-2-2b-it-xaas-kie 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-kie" # 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-kie", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lablup/gemma-2-2b-it-xaas-kie
- SGLang
How to use lablup/gemma-2-2b-it-xaas-kie 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-kie" \ --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-kie", "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-kie" \ --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-kie", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lablup/gemma-2-2b-it-xaas-kie with Docker Model Runner:
docker model run hf.co/lablup/gemma-2-2b-it-xaas-kie
XaaS Gemma 2 2B β Stage 3: KIE Fine-Tuning (Production Model)
Stage 3 of 4 in the XaaS fine-tuning pipeline for Korean international trade.
Fine-tuned from the QA model (lablup/gemma-2-2b-it-xaas-qa) for Key Information Extraction (KIE) from B2B supply-chain email threads. Given a multi-turn email conversation between a Korean buyer and an overseas supplier, the model extracts structured trade information (contract terms, parties, dates, prices, delivery schedule) as YAML. This is the production merged model deployed via vLLM in the XaaS API.
Pipeline Position
google/gemma-2-2b-it
β
lablup/gemma-2-2b-it-xaas-cpt
β
lablup/gemma-2-2b-it-xaas-qa
β [this model]
lablup/gemma-2-2b-it-xaas-kie β you are here (production)
Training Details
| Parameter | Value |
|---|---|
| Base model | lablup/gemma-2-2b-it-xaas-qa |
| Method | Supervised fine-tuning (SFT) with LoRA, then merged |
| LoRA rank (r) | 256 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Learning rate | 2e-3 |
| Max sequence length | 6,000 tokens |
| Batch size (effective) | 64 (2 per GPU Γ 16 gradient accumulation Γ 2 nodes) |
| Optimizer | paged_adamw_8bit |
| Precision | bfloat16 |
| Distributed training | DeepSpeed ZeRO-3, 2 nodes |
| Framework | HuggingFace TRL SFTTrainer + DeepSpeed |
The LoRA adapter has been merged into the base weights. Load directly with AutoModelForCausalLM (no PEFT dependency required).
Training Data
lablup/tariff_trade_domain.synthetic_trade_email_kie_kr β 1,188 synthetic B2B supply-chain email threads, each paired with a structured YAML extraction of:
- κ³μ½ λ° μ‘°κ±΄ (contract terms, payment conditions)
- μ°Έμ¬μ (buyer/supplier parties)
- λ μ§ / μ΄λ²€νΈ (dates, key milestones)
- κ°κ²© / λ°°μ‘ μ‘°κ±΄ (pricing, delivery schedule)
Generated by GPT-4o-mini across 20 industries (Aerospace, Technology, Manufacturing, Healthcare, ...).
How to Use
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "lablup/gemma-2-2b-it-xaas-kie"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
def extract_kie(email_thread: str) -> str:
prompt_text = (
"λ€μ μ΄λ©μΌ λνμμ κ³μ½ κ΄λ ¨ μ 보λ₯Ό YAML νμμΌλ‘ μΆμΆνμΈμ.\n\n"
f"{email_thread}"
)
messages = [{"role": "user", "content": prompt_text}]
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=1024, do_sample=False)
return tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
email = """
**Buyer Details:**
- Name: λ°μ§ν
- Company: SkyLine Aerospace Ltd.
**Email Exchange:**
From: jihoon.park@skylineaerospace.kr
Subject: νκ³΅μ© μ루미λ λΆν 100κ° κ²¬μ μμ²
...
"""
print(extract_kie(email))
# ```yaml
# κ³μ½ λ° μ‘°κ±΄:
# κ²°μ 쑰건: λ°°μ‘ μ κ²°μ
# λ°°μ‘ μΌμ : μ£Όλ¬Έ νμΈμΌλ‘λΆν° 2μ£Ό μ΄λ΄
# ...
OpenAI-compatible API (vLLM)
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
response = client.chat.completions.create(
model="xaas-gemma-2-2b-it-lora128",
messages=[{
"role": "user",
"content": "λ€μ μ΄λ©μΌ λνμμ κ³μ½ κ΄λ ¨ μ 보λ₯Ό YAML νμμΌλ‘ μΆμΆνμΈμ.\n\n{email_thread}"
}],
max_tokens=1024,
)
print(response.choices[0].message.content)
Production Deployment
Served with vLLM at --max-model-len 8128 and --tensor-parallel-size 1. Model weights are in float16, ~5 GB.
Expected Output Format
κ³μ½ λ° μ‘°κ±΄:
κ²°μ 쑰건: μ λΆ 50%, μκΈ λ°°μ‘ μ
λ°°μ‘ μΌμ : κ³μ½ 체결 ν 4μ£Ό
보μ¦: 12κ°μ
μ°Έμ¬μ:
ꡬ맀μ: λ°μ§ν, SkyLine Aerospace Ltd.
곡κΈμ
체: GlobalParts Inc.
λ μ§:
λ¬ΈμμΌ: 2024-07-26
μμ λ©κΈ°: 2024-08-23
μ΄λ²€νΈ:
- μ΄κΈ° λ¬Έμ λ° μ¬μ νμΈ
- κ°κ²© νμ (10% λλ ν μΈ μ μ©)
- μ΅μ’
κ³μ½ ν©μ
Limitations
- Training data is LLM-generated; extraction accuracy on real emails has not been independently verified
- YAML schema is fixed to the training format; highly irregular email structures may produce incomplete extractions
- Optimized for Korean-buyer / English-supplier email threads; pure Korean or pure English threads may work but were less represented in training
License
Built on Google Gemma 2 and subject to the Gemma Terms of Use.
- Downloads last month
- 7
Model tree for lablup/gemma-2-2b-it-xaas-kie
Base model
google/gemma-2-2b