Instructions to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit 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("peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit") 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
- Pi
How to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
VietPoet Qwen3.5-4B (MLX, 8-bit)
VietPoet-Qwen3.5-4B, a Qwen3.5-4B fine-tuned (QLoRA, 8,000
poems, 2 epochs) to write Vietnamese lục bát poems, converted to Apple's MLX
format with mlx_lm.convert -q --q-bits 8 (8.5 bits per weight, 4.5 GB). It is the near-lossless MLX version; the
4-bit version is about half the size. For other
systems see the 16-bit weights and the
GGUF files.
It is meant to be used with the line-by-line sampler and rule checker from github.com/peterbuitho/ThoLucBat. The macOS package in that repository (Apple silicon, LM Studio) sets everything up for you. Used on its own the model writes the right shape but breaks the tone rules more often.
What it does and does not do
With the sampler (16 samples per line, only lines that satisfy the 6/8 length, tone and rhyme rules are kept), on 40
held-out "8 câu" prompts served by mlx_lm.server on an Apple M2 Pro: rule score 0.992, 95% of poems fully
valid (the 16-bit model on vLLM: 0.994 and 98% on 100 prompts). Without the sampler the raw model scores about 0.81 and
breaks the 6th/8th-syllable tone rule in 38% of bát lines.
These numbers measure form, not poetry. Poems are correct lục bát but the meaning is often loose or off-topic (training prompts only had the poem title as topic). Judge the poetry yourself.
Run it
pip install mlx-lm
mlx_lm.server --model peterbuitho/VietPoet-Qwen3.5-4B-MLX-8bit --port 8080 --prompt-cache-size 0
Then start the page from the GitHub repository against that server:
VIETPOET_BASE_URL=http://127.0.0.1:8080/v1 VIETPOET_MODEL=default_model python -m app.webui
How mlx_lm.server (0.31.3) differs from vLLM, and what the sampler does about it:
--prompt-cache-size 0is needed: with the prompt cache on, the server's generation thread crashes (IndexError) as soon as a prompt exactly matches a cached one, which the line-by-line sampler causes on every line, and every later request then hangs.- The request's
modelmust bedefault_model(or the local path). Any other name is treated as a repository to load, and the server contacts huggingface.co to fetch it. nis ignored (always one completion), so the sampler asks for 16 lines with 16 single requests. Keep it to 8 at a time: 16 simultaneous connections get reset.logprobsmust betrue, not a number; an integer makes the server drop the connection.- The end-of-turn token
<|im_end|>comes back as text, so the sampler cuts candidate lines at the first special token.
Speed for one 8-line poem with 16 samples per line: about 75 to 85 seconds on an M2 Pro (16 GB) with mlx_lm.server.
Prompt format
Qwen chat format with thinking off, and the poem written by appending lines to the assistant turn:
<|im_start|>system
Bạn là nhà thơ Việt Nam chuyên sáng tác thơ lục bát.<|im_end|>
<|im_start|>user
Viết một bài thơ lục bát 8 câu về mùa thu quê em.<|im_end|>
<|im_start|>assistant
<think>
</think>
The request wording varies (several templates); they are in app/prompts.py in the GitHub repo.
Credits
- Training data: phamson02/vietnamese-poetry-corpus (CC BY 4.0), filtered to poems that pass a lục bát rule checker.
- Base model: Qwen/Qwen3.5-4B (Apache-2.0).
- Scoring idea: Vietnamese Poem Generation & the Prospect of Cross-Language Poem-to-Poem Translation (arXiv:2401.01078).
- Downloads last month
- 20
8-bit