diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-03-28 21:27:58 +0100 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-03-28 23:10:03 +0100 |
| commit | c47e900b94d18cca1bf600e58f10dbcc2e34c1f7 (patch) | |
| tree | bf7a4247c528841abe71bbbd408eda3ff71b1152 /pplx_embed_mlx.h | |
| parent | 34e9eefde7870edcc318209738cabb17c71b50ed (diff) | |
| download | ffwd-c47e900b94d18cca1bf600e58f10dbcc2e34c1f7.tar.gz ffwd-c47e900b94d18cca1bf600e58f10dbcc2e34c1f7.zip | |
Refactor and enhance pplx_embed and pplx_embed_mlx for improved model support
- Updated `pplx_embed.h` to support new embedding models: `pplx-embed-v1-4b` and `pplx-embed-context-v1-4b`.
- Simplified model configuration structure and constants for better maintainability.
- Enhanced comments for clarity on model architecture and configuration.
- Modified `pplx_embed_mlx.c` to streamline loading of model weights and configuration from `config.json`.
- Improved memory management and error handling in the MLX backend.
- Updated embedding computation to support dynamic hidden sizes based on model configuration.
- Added `pplx_mlx_config` function to retrieve model configuration details.
- Updated README.md
- Added .gitignore
Diffstat (limited to 'pplx_embed_mlx.h')
| -rw-r--r-- | pplx_embed_mlx.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/pplx_embed_mlx.h b/pplx_embed_mlx.h index 5327fd0..a1544ef 100644 --- a/pplx_embed_mlx.h +++ b/pplx_embed_mlx.h @@ -1,9 +1,7 @@ /* * pplx_embed_mlx.h - MLX GPU backend for pplx-embed inference * - * Uses Apple's mlx-c to run the transformer on Metal GPU. - * All operations run on the GPU default stream; the result is copied - * back to CPU as a float* embedding. + * Uses Apple's mlx-c to run the transformer on Metal. */ #ifndef PPLX_EMBED_MLX_H @@ -11,25 +9,26 @@ #include <stddef.h> #include <stdint.h> +#include "pplx_embed.h" /* Opaque MLX model context */ typedef struct pplx_mlx_ctx pplx_mlx_ctx_t; /* - * Load model into MLX arrays from safetensors in model_dir. + * Load model into MLX arrays from safetensors + config.json. * Returns NULL on error. */ pplx_mlx_ctx_t *pplx_mlx_load(const char *model_dir); -/* - * Free all MLX resources. - */ void pplx_mlx_free(pplx_mlx_ctx_t *ctx); /* * Compute embedding for token_ids[0..n_tokens-1]. - * Returns malloc'd float[1024] (caller frees). NULL on error. + * Returns malloc'd float[hidden_size] (caller frees). NULL on error. */ float *pplx_mlx_embed(pplx_mlx_ctx_t *ctx, const int *token_ids, int n_tokens); +/* Get the config (so main.c can read hidden_size etc.) */ +const pplx_config_t *pplx_mlx_config(const pplx_mlx_ctx_t *ctx); + #endif /* PPLX_EMBED_MLX_H */ |
