sentiment-gemma-3 / README.md
staedi's picture
Update README.md
98b2f14 verified
|
Raw
History Blame Contribute Delete
1.68 kB
---
language: en
pipeline_tag: text-generation
tags:
- mlx
library_name: mlx
license: gemma
base_model:
- mlx-community/gemma-3-4b-it-4bit
---
# staedi/sentiment-gemma-3
This model [staedi/sentiment-gemma-3](https://huggingface.co/staedi/sentiment-gemma-3) was
converted to MLX format from [mlx-community/gemma-3-4b-it-4bit](https://huggingface.co/mlx-community/gemma-3-4b-it-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-gemma-3")
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), \"entity_type\" (\"ORG\" for "
"companies/organizations, \"PERSON\" for individuals, \"GPE\" for countries/"
"cities/regions, \"OTHER\" for anything else), \"polarity\" (+ positive, "
"- negative, 0 neutral, ~ context-dependent), and \"category\" (one of: Legal, "
"Business, Performance, Recruitment, NewsRelease, Bankruptcy)."
)
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": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(
messages, tokenize=Falsse, add_generation_prompt=True, return_dict=False,
)
response = generate(model, tokenizer, prompt=prompt, verbose=False)
```