Feature Extraction
MLX
Safetensors
sentence-transformers
qwen3
mlx-embeddings
text-embeddings-inference
Instructions to use fcmeyer/F2LLM-v2-4B-mlx-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use fcmeyer/F2LLM-v2-4B-mlx-8bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir F2LLM-v2-4B-mlx-8bit fcmeyer/F2LLM-v2-4B-mlx-8bit
- sentence-transformers
How to use fcmeyer/F2LLM-v2-4B-mlx-8bit with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("fcmeyer/F2LLM-v2-4B-mlx-8bit") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
File size: 5,032 Bytes
a85ba20 | 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | ---
license: apache-2.0
language:
- en
- zh
- ru
- es
- fr
- de
- ar
- nl
- vi
- hi
- ko
- ja
- it
- id
- pt
- pl
- tr
- da
- th
- sv
- fa
- uk
- cs
- 'no'
- el
- ca
- ro
- fi
- bg
- tl
- gl
- my
- hy
- km
- ne
- hu
- eu
- he
- lo
- sw
- az
- lv
- si
- sk
- tg
- et
- lt
- ms
- hr
- is
- sl
- sr
- ur
- bn
- af
- ta
- ka
- te
- ml
- mn
- nn
- kk
- cy
- mr
- sq
- nb
- mk
- jv
- kn
- eo
- la
- gu
- uz
- am
- oc
- be
- mg
- vo
- pa
- lb
- ht
- br
- ga
- xh
- tt
- bs
- yo
base_model:
- codefuse-ai/F2LLM-v2-4B
base_model_relation: quantized
pipeline_tag: feature-extraction
library_name: mlx
tags:
- mlx
- mlx-embeddings
- sentence-transformers
- feature-extraction
- qwen3
datasets:
- codefuse-ai/F2LLM-v2
---
# fcmeyer/F2LLM-v2-4B-mlx-8bit
[codefuse-ai/F2LLM-v2-4B](https://huggingface.co/codefuse-ai/F2LLM-v2-4B) converted to native MLX format —
**8-bit (affine, group size 64)**, 4.0 GB on disk.
F2LLM-v2-4B is a 4B-parameter multilingual text embedding model from CodeFuse (Qwen3
trunk, 2560-dimensional embeddings, last-token pooling with L2 normalization). All credit
for the model belongs to the original authors; this repository only changes the weight
format so the model runs natively on Apple Silicon through
[mlx-embeddings](https://github.com/Blaizzy/mlx-embeddings).
## Usage
```bash
pip install mlx-embeddings
```
```python
from mlx_embeddings import load, generate
import mlx.core as mx
model, tokenizer = load("fcmeyer/F2LLM-v2-4B-mlx-8bit")
# Queries get the instruction prompt; documents do not.
query_prompt = "Instruct: Given a question, retrieve passages that can help answer the question.\nQuery: "
query = "What is F2LLM used for?"
documents = [
"We present F2LLM, a family of fully open embedding LLMs that achieve a strong balance between model size, training data, and embedding performance.",
"F2LLM is a model for computing text embeddings that can be used for various NLP tasks such as information retrieval, semantic search, and text classification.",
"F2LLM 是 CodeFuse 开源的系列嵌入模型。",
"F2LLM — это модель вычисления встраивания текста, которую можно использовать для различных задач НЛП, таких как поиск информации, семантический поиск и классификация текста."
]
# Pass max_length explicitly — generate() defaults to max_length=512 with
# truncation enabled, which silently clips longer inputs.
query_embedding = generate(model, tokenizer, texts=[query_prompt + query],
max_length=8192).text_embeds
document_embeddings = generate(model, tokenizer, texts=documents,
max_length=8192).text_embeds
similarity = query_embedding @ document_embeddings.T
print(similarity)
# [0.6342, 0.8541, 0.7194, 0.8373]
```
### Prompt format
Custom instructions follow the base model's format:
```text
Instruct: your_instruction
Query: your_query
```
For retrieval and reranking, prompt the queries and leave documents unprompted. For
symmetric tasks (STS, clustering, bitext mining) the model works with or without prompts
on both sides.
## Conversion
```bash
pip install "mlx-embeddings @ git+https://github.com/Blaizzy/mlx-embeddings@9b28270be81211f2b8daed0041aec65ea5dc4b28"
python -m mlx_embeddings.convert --hf-path codefuse-ai/F2LLM-v2-4B \
--mlx-path F2LLM-v2-4B-mlx-8bit --dtype bfloat16 -q --q-bits 8 --q-group-size 64
```
Converted with `mlx` 0.32.2 and `mlx-embeddings` 0.1.1
(commit [`9b28270be812`](https://github.com/Blaizzy/mlx-embeddings/commit/9b28270be81211f2b8daed0041aec65ea5dc4b28)).
All linear layers **and** the token embedding table are quantized to 8 bits with MLX affine quantization at group size 64. RMSNorm weights and the quantization scales/biases stay in bfloat16.
## Accuracy check
Each build was compared against a PyTorch bfloat16 reference run of the original
checkpoint on the 5-string fixture from the base model card (one prompted English query
plus four documents in English, Chinese, and Russian). Embeddings were re-normalized in
float32 before comparison, since bfloat16 output leaves vectors slightly off unit norm.
| Build | Size | Min cosine vs PyTorch | Max Δ on query→document similarity | Ranking preserved |
|---|---|---|---|---|
| `F2LLM-v2-4B-mlx-bf16` | 7.5 GB | 0.99984 | 0.0017 | yes |
| `F2LLM-v2-4B-mlx-8bit` **(this repo)** | 4.0 GB | 0.99954 | 0.0020 | yes |
| `F2LLM-v2-4B-mlx-6bit` | 3.1 GB | 0.99696 | 0.0078 | yes |
The PyTorch reference itself reproduces the similarity row published on the base model
card to within 0.005 (bfloat16 on CPU versus the card's bfloat16 on CUDA).
This is a small smoke-test fixture, not a benchmark. No MTEB or retrieval evaluation was
run on the quantized builds — if quantization loss matters for your task, measure it on
your own data.
## License
Apache 2.0, inherited from [codefuse-ai/F2LLM-v2-4B](https://huggingface.co/codefuse-ai/F2LLM-v2-4B).
|