GLiFormer Large v1 ONNX

ONNX weights for knowledgator/gliformer-large-v1, for use with fast_gliner. This repository does not include the PyTorch checkpoint.

FastGLiFormer exposes the same methods as FastGLiNER2. Relations come from the joint head, and structures are flat records.

from fast_gliner import FastGLiFormer

model = FastGLiFormer.from_pretrained("talmago/gliformer-large-v1-onnx")

Named entity recognition

model.predict_entities(
    "Marie Curie worked at the University of Paris in France.",
    ["person", "organization", "location"],
)
[
    {"text": "Marie Curie", "label": "person", "score": 0.999790, "start": 0, "end": 11},
    {"text": "University of Paris", "label": "organization", "score": 0.999745, "start": 26, "end": 45},
    {"text": "France", "label": "location", "score": 0.999939, "start": 49, "end": 55},
]

Text classification

classify returns every label score, highest first.

model.classify(
    "The new search feature is fast and easy to use.",
    ["positive", "negative", "neutral"],
)
[
    ("positive", 1.0),
    ("neutral", 0.0),
    ("negative", 0.0),
]

Relation extraction

Pass entity labels together with the relation schema. Endpoint labels constrain which pairs are kept.

model.extract_relations(
    "Alice works at Acme and lives in London.",
    ["person", "organization", "location"],
    [
        {
            "relation": "works_at",
            "subject_labels": ["person"],
            "object_labels": ["organization"],
        },
        {
            "relation": "lives_in",
            "subject_labels": ["person"],
            "object_labels": ["location"],
        },
    ],
)
Alice => works_at => Acme
Alice => lives_in => London

Structured extraction

Flat records use name::str for a single string. A bare field name, or any other suffix, is returned as a list.

model.extract_json(
    "Alice joined Acme as a software engineer.",
    {"employee": ["name::str", "company::str"]},
)
{
  "employee": [
    {"name": "Alice", "company": "Acme"}
  ]
}

Several tasks in one call

schema = (
    model.create_schema()
    .entities(["person", "organization"])
    .classification("topic", ["business", "sports", "technology"])
    .structure("employee")
    .field("name")
    .field("company")
)

model.extract("Alice joined Acme as a software engineer.", schema)

On this sentence the topic scores are technology 1.0, business 1.0, and sports 0.0. The employee record is name: Alice, company: Acme.

Files

onnx/encoder.onnx is the shared encoder. onnx/ner.onnx, onnx/classification.onnx, onnx/relations.onnx, and onnx/structuring.onnx are the task heads.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for talmago/gliformer-large-v1-onnx

Quantized
(2)
this model