Qwen2.5-7B-Ecom-Refiner (LoRA Adapter)
Qwen2.5-7B-Ecom-Refiner is a specialized LoRA adapter designed to enhance user-generated product descriptions for E-commerce platforms. It transforms raw, unstructured facts into professional, engaging, and well-structured sales copy.
📌 Overview
- Project Goal: Improve conversion rates and user experience (UX) on trading platforms by automating the creation of high-quality product listings.
- Base Model: Qwen/Qwen2.5-7B-Instruct
- Language: Russian (RU)
- Training Method: QLoRA (4-bit quantization)
🛠 Training Methodology
Dataset & Knowledge Distillation
The model was trained on a curated dataset of 1,500 examples created through knowledge distillation:
- Teacher Model: DeepSeek V3.
- Process: The teacher model generated "gold standard" descriptions based on raw, unstructured data from open E-commerce archives.
- Focus: Maintaining factual accuracy while improving readability and structure.
Technical Stack
- Libraries:
TRL,Transformers,PEFT. - Hardware: Optimized for training on 2x Tesla T4 GPUs.
- Quantization: 4-bit (QLoRA) to ensure efficient performance within 16-32 GB VRAM.
📊 Evaluation & Results
The model was evaluated using both semantic similarity and structural adherence metrics:
| Metric | Value | Description |
|---|---|---|
| BERTScore (F1) | 0.79 | High factual consistency and minimal hallucinations during paraphrasing. |
| Structure Adherence | 91% | Success rate in following the required format (bullet points, clear accents). |
🚀 Quick Start (Inference)
To use this adapter, you need to load the base Qwen2.5-7B-Instruct model and apply the LoRA weights. Below is an example based on the inference.py script:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
model_id = "Qwen/Qwen2.5-7B-Instruct"
adapter_id = "yuriy-magus/Qwen2.5-7B-Ecom-Refiner"
device = "cuda" if torch.cuda.is_available() else "cpu"
# 1. Load Tokenizer and Base Model
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16 if device == "cuda" else torch.float32,
device_map="auto" if device == "cuda" else None,
trust_remote_code=True
)
# 2. Load Adapter
model = PeftModel.from_pretrained(model, adapter_id)
model.to(device).eval()
# 3. Prepare Prompt (as used in training)
category = "Личные вещи / Одежда, обувь, аксессуары"
title = "Кеды pataugas"
original_desc = "Кеды фиpмы PATAUGAS. Кеды пoлнocтью кoжaные, пoдoшвa пpoшитa, мoлнии paбoчие. Сocтoяние хopoшее."
prompt = f"""### Instruction:
Отредактируй описание товара для Авито. Будь грамотным, добавь в текст структуру и привлекательность, а также строго придерживайся фактов из исходного текста.
### Context:
Категория: {category}
Товар: {title}
### Original Description:
{original_desc}
### Improved Description:
"""
# 4. Generate
inputs = tokenizer(prompt, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
temperature=0.7,
top_p=0.9,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result.split("### Improved Description:")[-1].strip())
- Downloads last month
- 1