Instructions to use Vineeth-AI/phi4-mini-wine-expert-qlora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Vineeth-AI/phi4-mini-wine-expert-qlora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-mini-instruct") model = PeftModel.from_pretrained(base_model, "Vineeth-AI/phi4-mini-wine-expert-qlora") - Notebooks
- Google Colab
- Kaggle
Phi-4-mini Wine Expert QLoRA
This repository contains a QLoRA adapter fine-tuned from microsoft/Phi-4-mini-instruct for wine-domain instruction following.
Intended tasks
The adapter is trained on three prompt families:
- Tasting note generation โ generate polished tasting notes from wine metadata.
- Structured attribute extraction โ extract body, tannin, acidity, sweetness, oak, aroma families, finish, and pairing hints from reviews.
- Explainable recommendation โ score a wine against a shopper preference and explain the match using review evidence.
Base model
- Base model:
microsoft/Phi-4-mini-instruct - Fine-tuning method: QLoRA / PEFT LoRA adapter
- Quantization during training: 4-bit NF4 with double quantization
Training data
The starter pipeline uses a Hugging Face Winemag-style dataset and converts each review into chat-style instruction examples. Structured labels are weak labels created from transparent wine-domain rules, not expert-certified sensory annotations.
Recommended improvement: mix in hand-labeled SipAI wines from trusted winery notes for higher-quality extraction and recommendation behavior.
Prompt format
Use a chat template with a system instruction and a task marker:
TASK: attribute_extraction
Extract structured wine attributes from this review.
...
Supported task markers:
tasting_note_generationattribute_extractionrecommendation_with_reasoning
Evaluation
will be updated soon.
| Metric | Value |
|---|---|
| JSON valid rate | TBD |
| Attribute level accuracy | TBD |
| Attribute macro-F1 | TBD |
| Tasting note ROUGE-L | TBD |
Example
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
base_model = "microsoft/Phi-4-mini-instruct"
adapter = "YOUR_USERNAME/phi4-mini-wine-expert-qlora"
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(base_model, quantization_config=bnb, device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(base, adapter)
messages = [
{"role": "system", "content": "You are SipAI Wine Expert. Return grounded, concise wine analysis."},
{"role": "user", "content": "TASK: attribute_extraction\nReview: Aromas of blackberry, cedar and graphite lead to a full-bodied palate with firm tannins and a long finish. Return valid JSON only."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=500, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Limitations
- The first version is a domain-adapted assistant, not a certified sommelier.
- Weak labels can encode rule-based mistakes.
- Recommendations are based on review text and metadata, not real inventory, user history, allergies, or medical considerations.
- The model may hallucinate unsupported tasting attributes if prompted poorly. Production use should validate JSON and ground outputs in retrieved wine records.
Safety and responsible use
This model is intended for wine description, extraction, search, and retail recommendation support. It should not be used to encourage unsafe alcohol consumption or make health claims.
Citation / attribution
Please attribute the base model and any dataset used in your final repository.
- Downloads last month
- 28
Model tree for Vineeth-AI/phi4-mini-wine-expert-qlora
Base model
microsoft/Phi-4-mini-instruct