CoolFace
Modelpublic

staedi/sentiment-llama-3.2

sourceHugging Facellama3.2updated 5mo agoView on Hugging Face
0likes25downloads
Model Card

staedi/sentiment-llama-3.2

This model staedi/sentiment-llama-3.2 was converted to MLX format from mlx-community/Llama-3.2-3B-Instruct-4bit using mlx-lm version 0.31.0.

Use with mlx

bash
pip install mlx-lm
python
from mlx_lm import load, generate

model, tokenizer = load("staedi/sentiment-llama-3.2")

prompt = (
  "You are a financial analyst specializing in directed sentiment extraction. "
  "Given a financial news text, identify all mentioned entities and determine "
  "the sentiment directed toward each one. Return your answer as a JSON array "
  "where each element has: \"entity\" (name), \"polarity\" (+ positive, - negative, "
  "0 neutral, ~ context-dependent), and \"category\" (one of: Legal, Business, "
  "Performance, Recruitment, NewsRelease, Bankruptcy).\n\n"
  "Valid polarities: \"+\", \"-\", \"0\", \"~\"\n"
)

 text = "Apple announced its earnings. The company performed well."
user_content = f"Extract the directed financial sentiment from the following text:\n\n{text}"

 if tokenizer.chat_template is not None:
  messages = [
      {"role": "system", "content": prompt},
      {"role": "user", "content": user_content},
  ]
  prompt = tokenizer.apply_chat_template(
      messages, add_generation_prompt=True, return_dict=False,
  )

 response = generate(model, tokenizer, prompt=prompt, verbose=True)