bestofaiml commited on
Commit
6af0b54
·
verified ·
1 Parent(s): 48c2230

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -63
app.py CHANGED
@@ -122,69 +122,7 @@ def ner(
122
 
123
 
124
  with gr.Blocks(title="GLiNER-M-v2.1") as demo:
125
- gr.Markdown(
126
- """
127
- # GLiNER-base
128
-
129
- GLiNER is a Named Entity Recognition (NER) model capable of identifying any entity type using a bidirectional transformer encoder (BERT-like). It provides a practical alternative to traditional NER models, which are limited to predefined entities, and Large Language Models (LLMs) that, despite their flexibility, are costly and large for resource-constrained scenarios.
130
-
131
- ## Links
132
-
133
- * Model: https://huggingface.co/urchade/gliner_multi-v2.1
134
- * All GLiNER models: https://huggingface.co/models?library=gliner
135
- * Paper: https://arxiv.org/abs/2311.08526
136
- * Repository: https://github.com/urchade/GLiNER
137
- """
138
- )
139
- with gr.Accordion("How to run this model locally", open=False):
140
- gr.Markdown(
141
- """
142
- ## Installation
143
- To use this model, you must install the GLiNER Python library:
144
- ```
145
- !pip install gliner
146
- ```
147
-
148
- ## Usage
149
- Once you've downloaded the GLiNER library, you can import the GLiNER class. You can then load this model using `GLiNER.from_pretrained` and predict entities with `predict_entities`.
150
- """
151
- )
152
- gr.Code(
153
- '''
154
- from gliner import GLiNER
155
-
156
- model = GLiNER.from_pretrained("urchade/gliner_mediumv2.1")
157
-
158
- text = """
159
- Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player. He has won 33 trophies in his career, including seven league titles, five UEFA Champions Leagues, the UEFA European Championship and the UEFA Nations League. Ronaldo holds the records for most appearances (183), goals (140) and assists (42) in the Champions League, goals in the European Championship (14), international goals (128) and international appearances (205). He is one of the few players to have made over 1,200 professional career appearances, the most by an outfield player, and has scored over 850 official senior career goals for club and country, making him the top goalscorer of all time.
160
- """
161
-
162
- labels = ["person", "award", "date", "competitions", "teams"]
163
-
164
- entities = model.predict_entities(text, labels)
165
-
166
- for entity in entities:
167
- print(entity["text"], "=>", entity["label"])
168
- ''',
169
- language="python",
170
- )
171
- gr.Code(
172
- """
173
- Cristiano Ronaldo dos Santos Aveiro => person
174
- 5 February 1985 => date
175
- Al Nassr => teams
176
- Portugal national team => teams
177
- Ballon d'Or => award
178
- UEFA Men's Player of the Year Awards => award
179
- European Golden Shoes => award
180
- UEFA Champions Leagues => competitions
181
- UEFA European Championship => competitions
182
- UEFA Nations League => competitions
183
- Champions League => competitions
184
- European Championship => competitions
185
- """
186
- )
187
-
188
  input_text = gr.Textbox(
189
  value=examples[0][0], label="Text input", placeholder="Enter your text here"
190
  )
 
122
 
123
 
124
  with gr.Blocks(title="GLiNER-M-v2.1") as demo:
125
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  input_text = gr.Textbox(
127
  value=examples[0][0], label="Text input", placeholder="Enter your text here"
128
  )