Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets new
  • Docs
  • Enterprise
  • Pricing

  • Log In
  • Sign Up

NbAiLab
/
borealis-1b-instruct-preview-mlx

Image-Text-to-Text
Transformers
Safetensors
MLX
Norwegian
Norwegian Bokmål
Norwegian Nynorsk
gemma3_text
text-generation
conversational
instruct
experimental
mlx-my-repo
text-generation-inference
🇪🇺 Region: EU
Model card Files Files and versions
xet
Community

Instructions to use NbAiLab/borealis-1b-instruct-preview-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • Transformers

    How to use NbAiLab/borealis-1b-instruct-preview-mlx with Transformers:

    # Use a pipeline as a high-level helper
    from transformers import pipeline
    
    pipe = pipeline("image-text-to-text", model="NbAiLab/borealis-1b-instruct-preview-mlx")
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
                {"type": "text", "text": "What animal is on the candy?"}
            ]
        },
    ]
    pipe(text=messages)
    # Load model directly
    from transformers import AutoTokenizer, AutoModelForCausalLM
    
    tokenizer = AutoTokenizer.from_pretrained("NbAiLab/borealis-1b-instruct-preview-mlx")
    model = AutoModelForCausalLM.from_pretrained("NbAiLab/borealis-1b-instruct-preview-mlx")
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
                {"type": "text", "text": "What animal is on the candy?"}
            ]
        },
    ]
    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 NbAiLab/borealis-1b-instruct-preview-mlx with MLX:

    # Make sure mlx-vlm is installed
    # pip install --upgrade mlx-vlm
    
    from mlx_vlm import load, generate
    from mlx_vlm.prompt_utils import apply_chat_template
    from mlx_vlm.utils import load_config
    
    # Load the model
    model, processor = load("NbAiLab/borealis-1b-instruct-preview-mlx")
    config = load_config("NbAiLab/borealis-1b-instruct-preview-mlx")
    
    # Prepare input
    image = ["http://images.cocodataset.org/val2017/000000039769.jpg"]
    prompt = "Describe this image."
    
    # Apply chat template
    formatted_prompt = apply_chat_template(
        processor, config, prompt, num_images=1
    )
    
    # Generate output
    output = generate(model, processor, formatted_prompt, image)
    print(output)
  • Inference
  • Notebooks
  • Google Colab
  • Kaggle
  • Local Apps
  • LM Studio
  • vLLM

    How to use NbAiLab/borealis-1b-instruct-preview-mlx with vLLM:

    Install from pip and serve model
    # Install vLLM from pip:
    pip install vllm
    # Start the vLLM server:
    vllm serve "NbAiLab/borealis-1b-instruct-preview-mlx"
    # Call the server using curl (OpenAI-compatible API):
    curl -X POST "http://localhost:8000/v1/chat/completions" \
    	-H "Content-Type: application/json" \
    	--data '{
    		"model": "NbAiLab/borealis-1b-instruct-preview-mlx",
    		"messages": [
    			{
    				"role": "user",
    				"content": [
    					{
    						"type": "text",
    						"text": "Describe this image in one sentence."
    					},
    					{
    						"type": "image_url",
    						"image_url": {
    							"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
    						}
    					}
    				]
    			}
    		]
    	}'
    Use Docker
    docker model run hf.co/NbAiLab/borealis-1b-instruct-preview-mlx
  • SGLang

    How to use NbAiLab/borealis-1b-instruct-preview-mlx 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 "NbAiLab/borealis-1b-instruct-preview-mlx" \
        --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": "NbAiLab/borealis-1b-instruct-preview-mlx",
    		"messages": [
    			{
    				"role": "user",
    				"content": [
    					{
    						"type": "text",
    						"text": "Describe this image in one sentence."
    					},
    					{
    						"type": "image_url",
    						"image_url": {
    							"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
    						}
    					}
    				]
    			}
    		]
    	}'
    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 "NbAiLab/borealis-1b-instruct-preview-mlx" \
            --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": "NbAiLab/borealis-1b-instruct-preview-mlx",
    		"messages": [
    			{
    				"role": "user",
    				"content": [
    					{
    						"type": "text",
    						"text": "Describe this image in one sentence."
    					},
    					{
    						"type": "image_url",
    						"image_url": {
    							"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
    						}
    					}
    				]
    			}
    		]
    	}'
  • Docker Model Runner

    How to use NbAiLab/borealis-1b-instruct-preview-mlx with Docker Model Runner:

    docker model run hf.co/NbAiLab/borealis-1b-instruct-preview-mlx
borealis-1b-instruct-preview-mlx
4.04 GB
Ctrl+K
Ctrl+K
  • 1 contributor
History: 12 commits
versae's picture
versae
Upload README.md with huggingface_hub
0b25753 verified 3 months ago
  • .gitattributes
    1.57 kB
    Upload tokenizer.json with huggingface_hub 3 months ago
  • README.md
    1.06 kB
    Upload README.md with huggingface_hub 3 months ago
  • added_tokens.json
    35 Bytes
    Upload added_tokens.json with huggingface_hub 3 months ago
  • chat_template.jinja
    1.53 kB
    Upload chat_template.jinja with huggingface_hub 3 months ago
  • config.json
    1.78 kB
    Upload config.json with huggingface_hub 3 months ago
  • generation_config.json
    219 Bytes
    Upload generation_config.json with huggingface_hub 3 months ago
  • model.safetensors
    4 GB
    xet
    Upload model.safetensors with huggingface_hub 3 months ago
  • model.safetensors.index.json
    24.8 kB
    Upload model.safetensors.index.json with huggingface_hub 3 months ago
  • special_tokens_map.json
    670 Bytes
    Upload special_tokens_map.json with huggingface_hub 3 months ago
  • tokenizer.json
    33.4 MB
    xet
    Upload tokenizer.json with huggingface_hub 3 months ago
  • tokenizer.model
    4.69 MB
    xet
    Upload tokenizer.model with huggingface_hub 3 months ago
  • tokenizer_config.json
    1.16 MB
    Upload tokenizer_config.json with huggingface_hub 3 months ago