Instructions to use masahiroid/Sentiment-Analysis-7B-4bit-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use masahiroid/Sentiment-Analysis-7B-4bit-mlx 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("masahiroid/Sentiment-Analysis-7B-4bit-mlx") 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 masahiroid/Sentiment-Analysis-7B-4bit-mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "masahiroid/Sentiment-Analysis-7B-4bit-mlx"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "masahiroid/Sentiment-Analysis-7B-4bit-mlx" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "masahiroid/Sentiment-Analysis-7B-4bit-mlx", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
Download chat_template.jinja from masahiroid/Sentiment-Analysis-7B-4bit-mlx: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/masahiroid/Sentiment-Analysis-7B-4bit-mlx/resolve/main/chat_template.jinja
- Command line
-
hf download hf://masahiroid/Sentiment-Analysis-7B-4bit-mlx/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/masahiroid/Sentiment-Analysis-7B-4bit-mlx/resolve/main/chat_template.jinja
1.06 kB
| {%- if messages[0]['role'] == 'system' %} | |
| {%- set system_message = messages[0]['content'] %} | |
| {%- set loop_messages = messages[1:] %} | |
| {%- else %} | |
| {%- set loop_messages = messages %} | |
| {%- endif %} | |
| {{- bos_token }} | |
| {%- for message in loop_messages %} | |
| {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %} | |
| {{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }} | |
| {%- endif %} | |
| {%- if message['role'] == 'user' %} | |
| {%- if loop.first and system_message is defined %} | |
| {{- ' [INST] ' + system_message + '\n\n' + message['content'] + ' [/INST]' }} | |
| {%- else %} | |
| {{- ' [INST] ' + message['content'] + ' [/INST]' }} | |
| {%- endif %} | |
| {%- elif message['role'] == 'assistant' %} | |
| {{- ' ' + message['content'] + eos_token}} | |
| {%- else %} | |
| {{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }} | |
| {%- endif %} | |
| {%- endfor %} | |