Views
No views yet
Qwen/Qwen2.5-0.5B-Instruct that extracts a strict,
closed-vocabulary JSON object from an unstructured app-store review:1{
2 "sentiment": "positive" | "negative" | "neutral",
3 "topics": [up to 3 strings from a fixed 8-term vocabulary],
4 "mentions_price": true | false,
5 "rating_implied": 1..5
6}ui, performance, bugs, ads, price, features,
usability, support.| Model | Aggregate | sentiment | topics | mentions_price | rating_implied |
|---|---|---|---|---|---|
| Base (3-shot, fp32) | 62.3% | 68.0% | 26.1% | 95.0% | 60.2% |
| Tuned (LoRA, 0-shot) | 76.6% | 72.5% | 73.5% | 97.5% | 62.7% |
topics (learning the
closed vocabulary). See Limitations below before trusting any single field.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5base = "Qwen/Qwen2.5-0.5B-Instruct"
6tok = AutoTokenizer.from_pretrained(base)
7model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.float32)
8model = PeftModel.from_pretrained(model, "tanmaydeshpande/qlora-app-review-extraction")
9model.eval()
10
11SYSTEM = ("You are an information-extraction engine. You read a short app review "
12 "and output ONLY a single JSON object. No prose, no code fences, no explanation.")
13INSTRUCTION = (
14 'Extract structured fields from the app review into a JSON object with EXACTLY these keys:\n'
15 ' "sentiment": one of "positive", "negative", "neutral"\n'
16 " \"topics\": a list of 0 to 3 strings, each chosen ONLY from this closed vocabulary: "
17 "['ui', 'performance', 'bugs', 'ads', 'price', 'features', 'usability', 'support']\n"
18 ' "mentions_price": true or false (does the review mention price, cost, subscription, or payment?)\n'
19 ' "rating_implied": an integer 1 to 5 (the star rating the text implies; 1 = very negative, 5 = very positive)\n'
20 "Output only the JSON object.")
21
22review = "Love the app but the ads are relentless and now they want $5/month to remove them."
23messages = [{"role": "system", "content": SYSTEM},
24 {"role": "user", "content": f'{INSTRUCTION}\n\nReview: "{review}"\nJSON:'}]
25prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26enc = tok(prompt, return_tensors="pt")
27out = model.generate(**enc, max_new_tokens=96, do_sample=False)
28print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))q,k,v,o,gate,up,down proj.bitsandbytes
4-bit QLoRA is CUDA-only and was not used — so the "quantization-recovery"
control row could not be produced on this machine (documented, not faked).sealuzh/app_reviews.sentiment, topics, and mentions_price labels are
generated by deterministic rules, so part of the tuned gain is the model
learning that labeling function rather than the underlying concept.rating_implied uses the dataset's native star rating and is the most
trustworthy field (exact accuracy 39.5% → 36.0% — roughly flat).mentions_price is ~96% one class (false), so its high accuracy is not
very informative.publication/limitations.md.sealuzh/app_reviews dataset — verify that dataset's terms for your use.