Text Generation
Transformers
Safetensors
MLX
qwen2
conversational
text-generation-inference
4-bit precision
Instructions to use fastx-ai/Marco-o1-1.2B-mlx-int4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fastx-ai/Marco-o1-1.2B-mlx-int4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fastx-ai/Marco-o1-1.2B-mlx-int4") model = AutoModelForCausalLM.from_pretrained("fastx-ai/Marco-o1-1.2B-mlx-int4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - MLX
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 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("fastx-ai/Marco-o1-1.2B-mlx-int4") 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
- vLLM
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fastx-ai/Marco-o1-1.2B-mlx-int4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fastx-ai/Marco-o1-1.2B-mlx-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fastx-ai/Marco-o1-1.2B-mlx-int4
- SGLang
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "fastx-ai/Marco-o1-1.2B-mlx-int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fastx-ai/Marco-o1-1.2B-mlx-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "fastx-ai/Marco-o1-1.2B-mlx-int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fastx-ai/Marco-o1-1.2B-mlx-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - MLX LM
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "fastx-ai/Marco-o1-1.2B-mlx-int4"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "fastx-ai/Marco-o1-1.2B-mlx-int4" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fastx-ai/Marco-o1-1.2B-mlx-int4", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use fastx-ai/Marco-o1-1.2B-mlx-int4 with Docker Model Runner:
docker model run hf.co/fastx-ai/Marco-o1-1.2B-mlx-int4
- Atomic Chat
fastx-ai/Marco-o1-int-4
The Model fastx-ai/Marco-o1-int-4 was converted to MLX format from AIDC-AI/Marco-o1 using mlx-lm version 0.20.1.
prompt="hello, can you teach me why 2 + 4 = 6 ?"
==========
Prompt: <|im_start|>system
你是一个经过良好训练的AI助手,你的名字是Marco-o1.
## 重要!!!!!
当你回答问题时,你的思考应该在<Thought>内完成,<Output>内输出你的结果。
<Thought>应该尽可能是英文,但是有2个特例,一个是对原文中的引用,另一个是是数学应该使用markdown格式,<Output>内的输出需要遵循用户输入的语言。
<|im_end|>
<|im_start|>user
hello, can you teach me why 2 + 4 = 6 ?<|im_end|>
<|im_start|>assistant
<Thought>
Alright, I need to explain why 2 plus 4 equals 6. Let's start by recalling the basic principles of addition. Addition is the process of combining two or more numbers to find their total. So, when we add 2 and 4, we're essentially combining two quantities.
First, let's visualize this. Imagine you have 2 apples and someone gives you 4 more apples. Now, how many apples do you have in total? Counting them out
==========
Prompt: 118 tokens, 698.640 tokens-per-sec
Generation: 100 tokens, 103.937 tokens-per-sec
Peak memory: 4.386 GB
Use with mlx
pip install mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("fastx-ai/Marco-o1-1.2B-mlx-int4")
prompt="hello"
if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None:
messages = [{"role": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
response = generate(model, tokenizer, prompt=prompt, verbose=True)
Change system prompt ...
clone this repo to local
change tokenizer_config.json
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\n\n你是一个经过良好训练的AI助手,你的名字是Marco-o1.\n \n## 重要!!!!!\n当你回答问题时,你的思考应该在<Thought>内完成,<Output>内输出你的结果。\n<Thought>应该尽可能是英文,但是有2个特例,一个是对原文中的引用,另一个是是数学应该使用markdown格式,<Output>内的输出需要遵循用户输入的语言。\n <|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
- load
from mlx_lm import load, generate
model, tokenizer = load("./mlx_model") # notice: folder where you put this repo files.
prompt="hello, can you teach me why 2 + 4 = 6 ?"
if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None:
messages = [{"role": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
response = generate(model, tokenizer, prompt=prompt, verbose=True)
- Downloads last month
- 17
Model size
8B params
Tensor type
U32
·
F16 ·
Hardware compatibility
Log In to add your hardware
4-bit
Model tree for fastx-ai/Marco-o1-1.2B-mlx-int4
Base model
ATH-MaaS/Marco-o1