FoodMapper GTE-Large (MLX Format)

This is thenlper/gte-large revision 4bef63f39fcc5e2d6b0aae83089f307af4970164, converted to MLX-Swift safetensors format for the FoodMapper macOS application.

Model Description

GTE-Large is a 335M parameter text embedding model that maps sentences to 1024-dimensional dense vectors. FoodMapper uses this conversion for food-description retrieval.

The converted weights use the safetensors format loaded by MLX-Swift on Apple Silicon.

Intended Use

  • Semantic food name matching (e.g., matching "granny smith apple" to "Apple, raw, with skin")
  • Food database harmonization between USDA FoodData Central, FooDB, and custom datasets
  • General text similarity on Apple Silicon Macs

Model Details

Property Value
Parameters 335M
Embedding Dimension 1024
Max Sequence Length 512
Architecture BERT
Precision float16
Format safetensors

Files

  • gte-large.safetensors - Model weights in safetensors format (~670MB)
  • config.json - Model architecture configuration
  • tokenizer.json - Tokenizer vocabulary and settings
  • tokenizer_config.json - Tokenizer configuration
  • vocab.txt - WordPiece vocabulary
  • special_tokens_map.json - Special token mappings

Usage with FoodMapper

FoodMapper offers this model as a one-time, user-started download during first-run setup.

Usage with MLX-Swift

import MLX
import MLXNN

// Load weights
let weights = try loadArrays(url: modelURL)
let parameters = ModuleParameters.unflattened(weights)
try model.update(parameters: parameters, verify: .none)

Pooling

GTE models use mean pooling over token embeddings (not CLS token pooling). The attention mask should be applied before averaging:

func meanPooling(_ hiddenState: MLXArray, attentionMask: MLXArray) -> MLXArray {
    let maskExpanded = attentionMask.expandedDimensions(axis: -1)
        .asType(hiddenState.dtype)
    let sumEmbeddings = (hiddenState * maskExpanded).sum(axis: 1)
    let sumMask = MLX.maximum(maskExpanded.sum(axis: 1), MLXArray(1e-9))
    return sumEmbeddings / sumMask
}

Original Model

Based on thenlper/gte-large revision 4bef63f39fcc5e2d6b0aae83089f307af4970164 by Alibaba DAMO Academy.

License

MIT, as declared by the pinned original GTE-Large revision.

Downloads last month
80
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for richtext/foodmapper-gte-large

Finetuned
(29)
this model