Downloads · 30 days
73
27% of all-time downloads
EdgeAIMed/gliner-relex-base-v1.0-mlx
gliner-relex-base-v1.0-mlx is a token classification model from EdgeAIMed. Use it when you need labels on individual words, such as names. It is set up for openmed. The card lists the license as apache-2.0.
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, an…
Downloads · 30 days
73
27% of all-time downloads
All-time downloads
274
Public
Repo size
900 MB
Likes
0
Public
Click a slice to open those files.
.safetensors900 MB · 99%
From the Hugging Face model README
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:
pip install "openmed[mlx]"OpenMedKitOpenMed/gliner-relex-base-v1.0-mlx performs experimental zero-shot relation extraction. You provide:
medication, condition, symptom, or proceduretreats, causes, associated with, or contraindicated forThe model returns extracted entities plus directed relation triples between entity pairs.
Artifact metadata:
zero-shot-relation-extractiongliner-uni-encoder-token-relexdeberta-v2 config family512weights.safetensorsGLiNERRelexMLXPipeline in Python and OpenMedRelationExtractor in SwiftInstall 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")
Add OpenMedKit to your Xcode project:
File > Add Package Dependencies.https://github.com/maziyarpanahi/openmed.OpenMedKit package product to your app target.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:
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"
}
relation_threshold, such as 0.9, for cleaner demos.medication over a long natural-language phrase.threshold and relation_threshold separately because entity recall and relation precision behave differently.512 token context window or chunk text before inference.knowledgator/gliner-relex-base-v1.0