Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return confidence in predict_entities #69

Closed
SergheiDinu opened this issue Apr 17, 2024 · 4 comments
Closed

Return confidence in predict_entities #69

SergheiDinu opened this issue Apr 17, 2024 · 4 comments

Comments

@SergheiDinu
Copy link

Hi,

I see as possible to return confidence from 'predict' into 'predict_entities'.
That way False Positive cases could be eliminated.

Best regards Dinu Serghei

@urchade
Copy link
Owner

urchade commented Apr 22, 2024

Hi @SergheiDinu , I am not sure to understand. Could you please state it differently ?

@SergheiDinu
Copy link
Author

Ah.. I mean to return confidence if it's possible.

@vk-maurya
Copy link

vk-maurya commented May 4, 2024

Hi @SergheiDinu ,

It is already in library you can use below code get scores.

from gliner import GLiNER
model = GLiNER.from_pretrained("urchade/gliner_medium")
model.eval()

text = """
Libretto by Marius Petipa, based on the 1822 novella ``Trilby, ou Le Lutin d'Argail`` by Charles Nodier, first presented by the Ballet of the Moscow Imperial Bolshoi Theatre on January 25/February 6 (Julian/Gregorian calendar dates), 1870, in Moscow with Polina Karpakova as Trilby and Ludiia Geiten as Miranda and restaged by Petipa for the Imperial Ballet at the Imperial Bolshoi Kamenny Theatre on January 17–29, 1871 in St. Petersburg with Adèle Grantzow as Trilby and Lev Ivanov as Count Leopold.
"""

labels = ["person", "book", "location", "date", "actor", "character"]

entities = model.predict_entities(text, labels, threshold=0.4)
# print(entities)
for entity in entities:
    print(entity["text"], "=>", entity["label"],"=>", entity["score"])  


@wjbmattingly
Copy link
Contributor

I have added this into gliner spacy for v. 0.0.8

@urchade urchade closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants