加载中…
加载中…
A fine-tuned version of Qwen/Qwen2.5-0.5B-Instruct trained with QLoRA and merged into standalone FP16 weights. Given a financial tweet or headline, it outputs strict JSON containing market sentiment (bearish, bullish, neutral) and extracted uppercase stock cashtags.
| Split / Setup | JSON-Valid % | Sentiment Macro-F1 | Ticker Exact-Match |
|---|---|---|---|
Zero-Shot Baseline (Qwen2.5-0.5B-Instruct) |
83.0% | 0.257 | 0.060 |
| Internal Validation Split (Day 4 QLoRA) | 100.0% | 0.862 | 0.996 |
Official Held-Out Test Split (validation, $N=2,388$) |
99.9% | 0.863 | 0.994 |
max_new_tokens=64. Tweets exceptionally dense with cashtags (15+ tickers) will have their ticker lists truncated mid-array. (Recommended to raise to max_new_tokens=128 if processing long-form multi-ticker posts in production).from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
MODEL_ID = "Badrdeen/qwen-financial-json-extractor"
tok = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.float16, device_map="auto")
SYSTEM = (
'Return only a JSON object with two keys: "sentiment" (one of bearish, bullish, neutral) '
'and "tickers" (list of cashtag symbols in the text, uppercase, without $; [] if none). No other text.'
)
msgs = [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": "$NVDA surges 8\% on strong AI demand while$INTC slips."}
]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))