File size: 2,868 Bytes
03300b3
 
 
 
 
 
 
 
 
4faa311
 
54b5699
 
 
 
4faa311
54b5699
50f7379
ee17529
3181180
ee17529
54c5e53
ee17529
 
54c5e53
ee17529
 
54c5e53
50f7379
 
4f89650
af347f8
ee17529
54c5e53
 
 
54b5699
54c5e53
54b5699
 
54c5e53
54b5699
 
 
 
 
 
 
 
54c5e53
 
54b5699
 
54c5e53
 
 
4f89650
54c5e53
 
 
ee17529
 
4f89650
ee17529
 
54c5e53
 
 
ee17529
 
4f89650
 
54c5e53
 
ee17529
 
54b5699
 
 
 
54c5e53
 
 
 
 
 
 
54b5699
54c5e53
 
54b5699
 
 
54c5e53
54b5699
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: README
emoji: πŸ“š
colorFrom: green
colorTo: indigo
sdk: static
pinned: false
---

# MLX Community

A community org for [MLX](https://github.com/ml-explore/mlx) model weights that run on Apple Silicon. This organization hosts ready-to-use models compatible with:
- [mlx-examples](https://github.com/ml-explore/mlx-examples) – a Python and CLI to run multiple types of models, including LLMs, image models, audio models, and more.
- [mlx-swift-examples](https://github.com/ml-explore/mlx-swift-examples) – a Swift package to run MLX models.
- [mlx-vlm](https://github.com/Blaizzy/mlx-vlm) – package for inference and fine-tuning of Vision Language Models (VLMs) using MLX.

These are pre-converted weights, ready to use in the example scripts or integrate in your apps.


# Quick start for LLMs

Install `mlx-lm`:

```
pip install mlx-lm
```

You can use `mlx-lm` from the command line. For example:

```
mlx_lm.generate --model mlx-community/Mistral-7B-Instruct-v0.3-4bit --prompt "hello"
```

This will download a Mistral 7B model from the Hugging Face Hub and generate
text using the given prompt. 

To chat with an LLM use:

```bash
mlx_lm.chat
```

This will give you a chat REPL that you can use to interact with the LLM. The
chat context is preserved during the lifetime of the REPL.

For a full list of options run `--help` on the command of your interest, for example:

```
mlx_lm.chat --help
```

## Conversion and Quantization

To quantize a model from the command line run:

```
mlx_lm.convert --hf-path mistralai/Mistral-7B-Instruct-v0.3 -q 
```

For more options run:

```
mlx_lm.convert --help
```

You can upload new models to Hugging Face by specifying `--upload-repo` to
`convert`. For example, to upload a quantized Mistral-7B model to the 
[MLX Hugging Face community](https://huggingface.co/mlx-community) you can do:

```
mlx_lm.convert \
    --hf-path mistralai/Mistral-7B-Instruct-v0.3 \
    -q \
    --upload-repo mlx-community/my-4bit-mistral
```

Models can also be converted and quantized directly in the
[mlx-my-repo](https://huggingface.co/spaces/mlx-community/mlx-my-repo) Hugging
Face Space.

For more details on the API checkout the full [README](https://github.com/ml-explore/mlx-examples/tree/main/llms)


### Other Examples:

For more examples, visit the [MLX Examples](https://github.com/ml-explore/mlx-examples) repo. The repo includes examples of:

- Image generation with Flux and Stable Diffusion
- Parameter efficient fine tuning with LoRA
- Speech recognition with Whisper
- Multimodal models such as CLIP or LLaVA

  and many other examples of different machine learning applications and algorithms.

For comprehensive support of VLMs, check [mlx-vlm](https://github.com/Blaizzy/mlx-vlm), and to integrate MLX natively in your apps use [mlx-swift-examples](https://github.com/ml-explore/mlx-swift-examples).