OpenMed GLiNER-Relex Base v1.0 MLX
This is a public OpenMed MLX artifact for zero-shot entity and relation extraction on Apple Silicon. It packages knowledgator/gliner-relex-base-v1.0 in the OpenMed MLX format so it can run locally in Python, macOS, and iOS apps through OpenMedKit.
OpenMed is the main developer experience:
- Website: openmed.life
- GitHub: github.com/maziyarpanahi/openmed
- Python:
pip install "openmed[mlx]" - Swift: add the OpenMed GitHub repository as a Swift Package and use
OpenMedKit
What This Model Does
OpenMed/gliner-relex-base-v1.0-mlx performs experimental zero-shot relation extraction. You provide:
- entity labels, such as
medication,condition,symptom, orprocedure - relation labels, such as
treats,causes,associated with, orcontraindicated for - input text
The model returns extracted entities plus directed relation triples between entity pairs.
Artifact metadata:
- OpenMed MLX task:
zero-shot-relation-extraction - OpenMed MLX family:
gliner-uni-encoder-token-relex - Backbone: DeBERTa-v3 /
deberta-v2config family - Max sequence length:
512 - Weight format:
weights.safetensors - Runtime APIs:
GLiNERRelexMLXPipelinein Python andOpenMedRelationExtractorin Swift - Runtime status: experimental
Python Quick Start
Install OpenMed with MLX support:
pip install -U "openmed[mlx]"
Run relation extraction from the Hub snapshot:
from huggingface_hub import snapshot_download
from openmed.mlx.inference import GLiNERRelexMLXPipeline
model_path = snapshot_download("OpenMed/gliner-relex-base-v1.0-mlx")
extractor = GLiNERRelexMLXPipeline(model_path)
result = extractor.inference(
"Aspirin was prescribed for headache after the patient reported migraine symptoms.",
labels=["medication", "condition", "symptom"],
relations=["treats", "associated with"],
threshold=0.5,
relation_threshold=0.9,
)
print(result["entities"])
print(result["relations"])
You can also load a local snapshot directory:
from openmed.mlx.inference import create_mlx_pipeline
extractor = create_mlx_pipeline("/path/to/gliner-relex-base-v1.0-mlx")
Swift And iOS Quick Start
Add OpenMedKit to your Xcode project:
- In Xcode, choose
File > Add Package Dependencies. - Paste
https://github.com/maziyarpanahi/openmed. - Add the
OpenMedKitpackage product to your app target. - Download this MLX artifact once, then reuse the cached local model for offline inference.
Example:
import OpenMedKit
let modelURL = try await OpenMedModelStore.downloadMLXModel(
repoID: "OpenMed/gliner-relex-base-v1.0-mlx"
)
let extractor = try OpenMedRelationExtractor(modelDirectoryURL: modelURL)
let result = try extractor.extract(
"Aspirin was prescribed for headache after the patient reported migraine symptoms.",
entityLabels: ["medication", "condition", "symptom"],
relationLabels: ["treats", "associated with"],
threshold: 0.5,
relationThreshold: 0.9
)
for entity in result.entities {
print(entity.label, entity.text, entity.score)
}
for relation in result.relations {
print(relation.head.text, relation.label, relation.tail.text, relation.score)
}
Notes for Apple apps:
- MLX inference runs on Apple Silicon and supported Apple devices.
- The iOS Simulator is not the acceptance target for MLX inference; test on a physical iPhone or iPad.
- After the first model download, inference is local and does not require a server.
Prompt Format
The artifact includes OpenMed prompt-packing metadata so Python and Swift build the same input sequence:
{
"kind": "gliner-relex",
"entity_token": "<<ENT>>",
"relation_token": "<<REL>>",
"separator_token": "<<SEP>>",
"class_token_index": 128001,
"rel_token_index": 128003,
"embed_marker_token": true,
"split_mode": "words"
}
Practical Guidance
- Start with a conservative
relation_threshold, such as0.9, for cleaner demos. - Use concise labels. For example, prefer
medicationover a long natural-language phrase. - Tune
thresholdandrelation_thresholdseparately because entity recall and relation precision behave differently. - Keep inputs under the artifact's
512token context window or chunk text before inference. - Treat this runtime as experimental while OpenMed continues parity testing across Python MLX and Swift MLX.
Credits
- Base checkpoint:
knowledgator/gliner-relex-base-v1.0 - OpenMed GitHub: github.com/maziyarpanahi/openmed
- OpenMed website: openmed.life
- MLX packaging, Python runtime, and Swift runtime: OpenMed
- Downloads last month
- 2,244
Quantized
Model tree for OpenMed/gliner-relex-base-v1.0-mlx
Base model
knowledgator/gliner-relex-base-v1.0