Description
The text classification example from the documentation fails with an AttributeError when calling GLiNERClassifier.
Documentation example:
from gliner import GLiNER
from gliner.multitask import GLiNERClassifier
# Initialize
model = GLiNER.from_pretrained("knowledgator/gliner-multitask-large-v0.5")
classifier = GLiNERClassifier(model=model)
# Single-label classification
text = "SpaceX successfully launched a new rocket into orbit."
labels = ['science', 'technology', 'business', 'sports']
predictions = classifier(text, classes=labels, multi_label=False)
print(predictions)
Error
AttributeError: 'UniEncoderTokenGLiNER' object has no attribute 'run'
Full traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/tmp/ipykernel_707/4252357861.py in <cell line: 0>()
----> 1 predictions = classifier(text, classes=labels, multi_label=False)
2 print(predictions)
1 frames
/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py in __getattr__(self, name)
1966 if name in modules:
1967 return modules[name]
-> 1968 raise AttributeError(
1969 f"'{type(self).__name__}' object has no attribute '{name}'"
1970 )
AttributeError: 'UniEncoderTokenGLiNER' object has no attribute 'run'
Environment
- Python: 3.12
- GLiNER version: 0.2.26
Steps to Reproduce
ˋˋˋ
! pip install tiktoken
! pip install sentencepiece protobuf
! pip install gliner[gpu]
! pip install -U langchain-text-splitters
! pip install evaluate
! pip install flashdeberta -U
ˋˋˋ
from gliner import GLiNER
from gliner.multitask import GLiNERClassifier
model = GLiNER.from_pretrained("knowledgator/gliner-multitask-large-v0.5")
classifier = GLiNERClassifier(model=model)
text = "SpaceX successfully launched a new rocket into orbit."
labels = ['science', 'technology', 'business', 'sports']
predictions = classifier(text, classes=labels, multi_label=False)
Expected Behavior
The classifier should return a prediction similar to the documentation example.
Description
The text classification example from the documentation fails with an
AttributeErrorwhen callingGLiNERClassifier.Documentation example:
Error
Full traceback:
Environment
Steps to Reproduce
ˋˋˋ
! pip install tiktoken
! pip install sentencepiece protobuf
! pip install gliner[gpu]
! pip install -U langchain-text-splitters
! pip install evaluate
! pip install flashdeberta -U
ˋˋˋ
Expected Behavior
The classifier should return a prediction similar to the documentation example.