masabhuq/stl_phones_new_spec_format
Viewer • Updated • 11 • 10
How to use masabhuq/stl_phone_summarizer with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit")
model = PeftModel.from_pretrained(base_model, "masabhuq/stl_phone_summarizer")How to use masabhuq/stl_phone_summarizer with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "summarization" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("summarization", model="masabhuq/stl_phone_summarizer") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("masabhuq/stl_phone_summarizer", dtype="auto")How to use masabhuq/stl_phone_summarizer with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for masabhuq/stl_phone_summarizer to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for masabhuq/stl_phone_summarizer to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for masabhuq/stl_phone_summarizer to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="masabhuq/stl_phone_summarizer",
max_seq_length=2048,
)masabhuq/stl_phone_summarizer python model.cpu() torch.cuda.empty_cache() specs_list.json) containing pairs of detailed phone specifications and their corresponding summaries. Each entry includes:
- specs: Detailed technical specs (e.g., display size, chipset, camera details).
- output: A concise summary in the format:
Display: [summary] Processor: [name] Camera: [highlights] Battery: [capacity and charging] Others: [features]
The dataset emphasizes consumer-friendly features like high refresh rates, fast charging, and water resistance, avoiding overly technical terms. bibtex @misc{stl_phone_summarizer, author = {masabhuq}, title = {STL Phone Summarizer: A Fine-Tuned Llama-3.2 Model for Phone Specification Summaries}, year = {2025}, publisher = {Hugging Face}, howpublished = {\url{https://huggingface.co/masabhuq/stl_phone_summarizer}} }
### 6. Clean Up
Free GPU memory after inference:
python model.cpu() torch.cuda.empty_cache() masabhuq/stl_phone_summarizer
pip install unsloth torch
from unsloth import FastLanguageModel
from unsloth.chat_templates import get_chat_template
model, tokenizer = FastLanguageModel.from_pretrained(
"masabhuq/stl_phone_summarizer",
max_seq_length=2048,
dtype=None, # Auto-detect (bfloat16 if supported)
load_in_4bit=True, # 4-bit quantization for memory efficiency
)
FastLanguageModel.for_inference(model)
tokenizer = get_chat_template(
tokenizer,
chat_template="llama-3.2",
map_eos_token=True,
)
system_prompt = (
"You are an expert at summarizing phone specifications into short, appealing key descriptions for an e-commerce site. "
"Always output in exactly this format:\n"
"Display: [concise display summary]\n"
"Processor: [processor name]\n"
"Camera: [camera highlights]\n"
"Battery: [battery capacity and charging]\n"
"Others: [comma-separated unique features]. "
"Focus on desirable aspects like high refresh rates, zoom capabilities, fast charging, and unique features such as water resistance or special sensors. "
"Do not include complicated keyboards that don't make sense on their own. "
"Do not include words that are too technical to understand for someone who is not highly tech savvy. "
"Output should be within 280 characters. Don't include anything like IPDC or IP64 or any such features in the result. Words starting with IP are not to be considered display feature."
)
specs = "Build: Glass front (Gorilla Glass 5), silicone polymer back (eco leather), plastic frame\nWeight: 178 g ..."
prompt = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": specs}
]
formatted_prompt = tokenizer.apply_chat_template(
prompt,
tokenize=False,
add_generation_prompt=True,
)
import torch
inputs = tokenizer(formatted_prompt, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
temperature=0.7,
top_p=0.9,
)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=False)
# Extract the last paragraph and clean up
paragraphs = generated_text.strip().split("\n\n")
last_paragraph = paragraphs[-1]
clean_last_paragraph = last_paragraph.split("<|eot_id|>")[0].strip()
print(clean_last_paragraph)
python model.cpu() torch.cuda.empty_cache()
model.cpu()).model.cpu() and torch.cuda.empty_cache() to free GPU memory after inference, especially on low-VRAM GPUs.temperature and top_p for more or less creative outputs, and max_new_tokens for longer or shorter summaries.unsloth/Llama-3.2-3B-Instruct-bnb-4bitr=16, targeting modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"].specs) paired with concise summaries (output) in the format shown above.trl.SFTTrainer, train_on_responses_only to focus on assistant responses, and Llama-3.2 chat template for single-turn interactions.specs_list.json) containing pairs of detailed phone specifications and their corresponding summaries. Each entry includes:
- specs: Detailed technical specs (e.g., display size, chipset, camera details).
- output: A concise summary in the format:
Display: [summary] Processor: [name] Camera: [highlights] Battery: [capacity and charging] Others: [features]
The dataset emphasizes consumer-friendly features like high refresh rates, fast charging, and water resistance, avoiding overly technical terms.
This model is licensed under the Apache 2.0 License. See the LICENSE file in the repository for details.
bibtex @misc{stl_phone_summarizer, author = {masabhuq}, title = {STL Phone Summarizer: A Fine-Tuned Llama-3.2 Model for Phone Specification Summaries}, year = {2025}, publisher = {Hugging Face}, howpublished = {\url{https://huggingface.co/masabhuq/stl_phone_summarizer}} }
### 6. Clean Up
Free GPU memory after inference:
python model.cpu() torch.cuda.empty_cache()