Downloads · 30 days
10
9% of all-time downloads
leonpham1208/alpha-ner-bi-transformer
alpha-ner-bi-transformer is a feature extraction model from leonpham1208. Use it when you need embeddings to search or compare text. It is set up for transformers.
This code demonstrates how to use the GLiNER model for Named Entity Recognition (NER) tasks. The model is loaded from the Hugging Face Hub and fine-tuned to predict entities such as 'product', 'productdetail', 'user',…
Downloads · 30 days
10
9% of all-time downloads
All-time downloads
109
Public
Repo size
613 MB
Likes
1
Public
Click a slice to open those files.
.bin611 MB · 98%
From the Hugging Face model README
This code demonstrates how to use the GLiNER model for Named Entity Recognition (NER) tasks. The model is loaded from the Hugging Face Hub and fine-tuned to predict entities such as 'product', 'product_detail', 'user', 'level', and 'date_range' from a given query.
Steps:
predict_entities method to extract entities with a specified confidence threshold.This example is useful for tasks like extracting structured information from unstructured text queries.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
!pip install gliner
!pip install accelerate -U
from gliner import GLiNER
import torch
device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
model = GLiNER.from_pretrained("leonpham1208/alpha-ner-bi-transformer")
model.to(device)
labels = ["product", "product_detail", "user", "level", "date_range"]
query = "Get me a Win Loss Detail Report yesterday"
entities = model.predict_entities(query, labels, threshold=0.9)
from spacy import displacy
queries = [
"Get me a Win Loss Detail Report yesterday",
"Get me a Win Loss Detail Report on day 10",
"Win Loss Detail Report from 1/1 to 31/1",
"Get me a Win Loss Detail Report for Direct Member who played Product Detail Sportsbook in Sportsbook Product from 01/02/2024 to 15/02/2024",
"Give me my Win Loss Detail report last week",
"Give me a Win Loss Detail report for Sportsbook from last week.",
"Give me my Win Loss Detail report last week",
"Get me a Win Loss Detail Report of master1",
"Win/Loss details for Product Sportsbook"
]
labels = ["product", "product_detail", "user", "level", "date_range"]
for query in queries:
entities = trained_model.predict_entities(query, labels, threshold=0.9)
dic_ents = {
"text": query,
"ents": entities,
"title": None
}
print(f"🫂 Query: {query}")
print(f"😍 Entity: ")
displacy.render(dic_ents, manual=True, style='ent')
print("🤖==========================================================================================🤖")
print("\n")