Dedicated Endpoints

Run this model inference on single tenant GPU with unmatched speed and reliability at scale.

Learn more
Container

Run this model inference with full control and performance in your environment.

Learn more

Get help setting up a custom Dedicated Endpoints.

Talk with our engineer to get a quote for reserved GPU instances with discounts.

README

License: mit

Model Details

Base modelGPT-2 (124M)
MethodLoRA (r=8, alpha=16)
Trainable params~300K (0.24%)
Target modulesc_attn
v1 datasetFinancial PhraseBank — 4,840 examples, 3 epochs
v2 datasetNOSIBLE Financial Sentiment — 100K examples, 1 epoch
Max length256
Learning rate1e-4 (reduced for stacked fine-tuning)

Usage

python

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
tokenizer = AutoTokenizer.from_pretrained("poseidon1113/gpt2-lora-financial-sentiment-v2")
model = PeftModel.from_pretrained(
AutoModelForCausalLM.from_pretrained("gpt2", torch_dtype=torch.float16),
"poseidon1113/gpt2-lora-financial-sentiment-v2"
).eval()
def predict(sentence):
inputs = tokenizer(f"### Sentence:\n{sentence}\n\n### Sentiment:\n", return_tensors="pt")
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=10, do_sample=False,
pad_token_id=tokenizer.eos_token_id)
result = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:],
skip_special_tokens=True).strip().lower()
return next((w for w in result.split() if w in ("positive", "negative", "neutral")), "neutral")
predict("Operating profit rose to EUR 13.1 mn from EUR 21.1 mn.") # → positive
predict("The company reported a loss for the third consecutive quarter.") # → negative

Evaluation on FiQA 2018 (all splits combined)

ClassCorrectTotalAccuracy
Positive21070629.7%
Neutral8211571.3%
Negative21337357.1%
Overall505119442.3%

Comparison with v1

v1 (PhraseBank only)v2 (+ NOSIBLE)
Training examples4,840+100,000
Overall accuracy42.3%

Limitations

  • GPT-2 is a small model — larger base (e.g. Llama, Mistral) would improve accuracy significantly
  • Works best on single sentences or short paragraphs
  • May still show neutral bias inherited from PhraseBank distribution

Citation

bibtex

@article{Malo2014GoodDO,
title={Good Debt or Bad Debt: Detecting Semantic Orientations in Economic Texts},
author={P. Malo and A. Sinha and P. Korhonen and J. Wallenius and P. Virtanen},
journal={Journal of the Association for Information Science and Technology},
year={2014}, volume={65}
}

Model provider

poseidon1113

Model tree

Base

openai-community/gpt2

Adapter

this model

Modalities

Input

Text

Output

Text

Pricing

Dedicated Endpoints

View details

Supported Functionality

Model APIs

Dedicated Endpoints

Container

More information

Explore FriendliAI today