zero-shot NER

FREEMIUM
By Knowledgator | Updated a month ago | Text Analysis
Popularity

9.3 / 10

Latency

423ms

Service Level

100%

Health Check

N/A

Back to All Tutorials (1)

Visalize API with Gradio

Named Entity Recognition (NER) has emerged as a fundamental task for many NLP applications. It involves the intricate process of detecting specific entities within a body of text and subsequently categorising them into predefined classes. Traditionally, the development of an effective NER system necessitated vast amounts of labelled data, the annotation of which was an arduous task. We have developed the system that can achive high level of generalization, while having benefits of traditional approaches, such as highlighting of entities, scoring them and fast execution.

In this tutorial we will use our API in couple with Gradio to build app for visualization of its work.

Here we will demonstrate how to use it and explore the possibilities of our API with nice visualization from Gradio.

To install Gradio run the following command:

pip install gradio

Here is a code for running our API with Gradio, you need just place your actual API_KEY.

import gradio as gr
import requests


API_KEY = ‘’


def call_zero_shot_ner(text, labels):
   url = "https://zero-shot-ner.p.rapidapi.com/predict"


   payload = {
   "text": text,
   "labels": labels
   }


   headers = {
       "content-type": "application/json",
       "X-RapidAPI-Key": API_KEY,
       "X-RapidAPI-Host": "zero-shot-ner.p.rapidapi.com"
   }
   response = requests.post(url, json=payload, headers=headers)
   return response


def predict(labels, text):
   labels = labels.split(', ')
   response = call_zero_shot_ner(text, labels).json()
   return response
  
demo = gr.Interface(fn=predict, inputs = ["text", "text"], outputs = gr.HighlightedText())


demo.launch(share = True)

After execution of the script above, you will get generated URL to share this App with any on the Internet.

To use it, you just need to put labels separated by commas and text in the appropriate input blocks.