Instructions to use staedi/sentiment-gemma-3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use staedi/sentiment-gemma-3 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("staedi/sentiment-gemma-3") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use staedi/sentiment-gemma-3 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "staedi/sentiment-gemma-3"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "staedi/sentiment-gemma-3" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "staedi/sentiment-gemma-3", "messages": [ {"role": "user", "content": "Hello"} ] }'
| 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) | |
| ``` |