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
Generated by GPT-4o-mini across 20 industries (Aerospace, Technology, Manufacturing, Healthcare, ...).
How to Use
python
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
34model_id ="lablup/gemma-2-2b-it-xaas-kie"56tokenizer = AutoTokenizer.from_pretrained(model_id)7model = AutoModelForCausalLM.from_pretrained(8 model_id,9 torch_dtype=torch.float16,10 device_map="auto",11)1213defextract_kie(email_thread:str)->str:14 prompt_text =(15"다음 이메일 대화에서 계약 관련 정보를 YAML 형식으로 추출하세요.\n\n"16f"{email_thread}"17)18 messages =[{"role":"user","content": prompt_text}]19 prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)20 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)21with torch.no_grad():22 outputs = model.generate(**inputs, max_new_tokens=1024, do_sample=False)23return tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)2425email ="""
26**Buyer Details:**
27- Name: 박지훈
28- Company: SkyLine Aerospace Ltd.
2930**Email Exchange:**
31From: jihoon.park@skylineaerospace.kr
32Subject: 항공용 알루미늄 부품 100개 견적 요청
33...
34"""35print(extract_kie(email))36# ```yaml37# 계약 및 조건:38# 결제 조건: 배송 시 결제39# 배송 일정: 주문 확인일로부터 2주 이내40# ...
OpenAI-compatible API (vLLM)
python
1from openai import OpenAI
23client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")4response = client.chat.completions.create(5 model="xaas-gemma-2-2b-it-lora128",6 messages=[{7"role":"user",8"content":"다음 이메일 대화에서 계약 관련 정보를 YAML 형식으로 추출하세요.\n\n{email_thread}"9}],10 max_tokens=1024,11)12print(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
yaml
1계약 및 조건:2결제 조건: 선불 50%, 잔금 배송 시
3배송 일정: 계약 체결 후 4주
4보증: 12개월
5참여자:6구매자: 박지훈, SkyLine Aerospace Ltd.
7공급업체: GlobalParts Inc.
8날짜:9문의일:2024-07-2610예상 납기:2024-08-2311이벤트:12- 초기 문의 및 사양 확인
13- 가격 협상 (10% 대량 할인 적용)
14- 최종 계약 합의
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