Views
No views yet

1# until the new pip release, install from main to use the new architecture
2pip install git+https://github.com/urchade/GLiNER.gitlabel in the list of labels, please check example below:1from gliner import GLiNER
2
3model = GLiNER.from_pretrained("knowledgator/gliner-decoder-base-v1.0")
4
5text = "Hugging Face is a company that advances and democratizes artificial intelligence through open source and science."
6
7labels = ["label"]
8
9model.predict_entities(text, labels, threshold=0.3, num_gen_sequences=1)1from gliner import GLiNER
2
3model = GLiNER.from_pretrained("knowledgator/gliner-decoder-base-v1.0")
4
5text = (
6 "Apple was founded as Apple Computer Company on April 1, 1976, "
7 "by Steve Wozniak, Steve Jobs (1955–2011) and Ronald Wayne to "
8 "develop and sell Wozniak's Apple I personal computer."
9)
10
11labels = ["person", "company", "date"]
12
13model.run([text], labels, threshold=0.3, num_gen_sequences=1)1[
2 [
3 {
4 "start": 21,
5 "end": 26,
6 "text": "Apple",
7 "label": "company",
8 "score": 0.6795641779899597,
9 "generated labels": ["Organization"]
10 },
11 {
12 "start": 47,
13 "end": 60,
14 "text": "April 1, 1976",
15 "label": "date",
16 "score": 0.44296327233314514,
17 "generated labels": ["Date"]
18 },
19 {
20 "start": 65,
21 "end": 78,
22 "text": "Steve Wozniak",
23 "label": "person",
24 "score": 0.9934439659118652,
25 "generated labels": ["Person"]
26 },
27 {
28 "start": 80,
29 "end": 90,
30 "text": "Steve Jobs",
31 "label": "person",
32 "score": 0.9725918769836426,
33 "generated labels": ["Person"]
34 },
35 {
36 "start": 107,
37 "end": 119,
38 "text": "Ronald Wayne",
39 "label": "person",
40 "score": 0.9964536428451538,
41 "generated labels": ["Person"]
42 }
43 ]
44]1model.run(
2 text, labels,
3 threshold=0.3,
4 num_gen_sequences=1,
5 gen_constraints=[
6 "organization", "organization type", "city",
7 "technology", "date", "person"
8 ]
9)pip install cython