Named Entity Recognition (NER)

Overview

Extract named entities (people, organizations, locations, dates, monetary amounts) from unstructured Indic text using Named Entity Recognition (NER) models trained on diverse regional corpora.

Getting started

  1. Get an inference API key from the Bhashini portal.
  2. Choose an NER service ID corresponding to the source language.
  3. Send input text in the request payload.
  4. Receive extracted entities with token classification tags and character span offsets.

Entity taxonomy

  • PER (Person): Names of individuals, ministers, authors (e.g., रविंद्रनाथ टैगोर)
  • LOC / GPE (Location): Cities, states, monuments, geographical regions (e.g., नई दिल्ली, कर्नाटक)
  • ORG (Organization): Government bodies, enterprises, universities (e.g., भारतीय रिज़र्व बैंक)
  • DATE & TIME: Temporal expressions and calendar milestones (e.g., १५ अगस्त)
  • MONEY & NUM: Currencies and numerical quantifiers (e.g., ५०० रुपये)

Parsing entity spans in code

Each detected entity contains the matched token, category tag, and character index boundaries for inline text highlighting:

for entity in result["pipelineResponse"][0]["output"][0]["nerPrediction"]:
    print(f"[{entity['tag']}] '{entity['token']}' (offset: {entity.get('startOffset', 0)}..{entity.get('endOffset', 0)})")

Interactive playground

Try NER
Provide Indic text and extract named entities with token labels
Request
Add an inference API key to run.
curl
curl --location 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline' \
--header 'Accept: */*' \
--header 'Authorization: YOUR_INFERENCE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"pipelineTasks": [
{
"taskType": "ner",
"config": {
"serviceId": "",
"language": {
"sourceLanguage": "hi"
}
}
}
],
"inputData": {
"input": [
{
"source": "<text>"
}
]
}
}'
Response
Send a request to see the live response here.

Code examples

const url = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';


const payload = {
  pipelineTasks: [{
    taskType: 'ner',
    config: {
      language: { sourceLanguage: 'hi' },
      serviceId: '<NER_SERVICE_ID>'
    }
  }],
  inputData: {
    input: [{ source: 'प्रधानमंत्री नई दिल्ली में भारतीय रिज़र्व बैंक के अधिकारियों से मिले।' }]
  }
};


const res = await fetch(url, {
  method: 'POST',
  headers: {
    'Accept': '*/*',
    'Authorization': '<YOUR_INFERENCE_API_KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(payload)
});


const data = await res.json();
const entities = data.pipelineResponse[0].output[0].nerPrediction;
console.log("Extracted Entities:", entities);