magbert-ner-api / README.md
hassoudi's picture
Upload README.md
2b67506 verified
metadata
title: Magbert Ner Api
emoji: πŸƒ
colorFrom: yellow
colorTo: indigo
sdk: docker
pinned: false
short_description: magbert-ner-fr-api

Private BERT NER API on Hugging Face Space

This repo contains a private FastAPI-based NER API built on a Hugging Face BERT model.

Features

  • Private Hugging Face model loading
  • FastAPI REST endpoint for NER
  • Token-based authentication (X-API-KEY)
  • Rate limiting per IP using slowapi
  • Usage tracking per API key

Run locally

export HF_TOKEN=your_hf_token
export X-API-KEY=your-secret-key
uvicorn app:app --reload

Example request

curl -X POST http://localhost:8000/ner \
 -H "X-API-KEY: your-secret-key" \
 -H "Content-Type: application/json" \
 -d '{"text": "Barack Obama was the president of the United States."}'

Deployment

Can be deployed to Hugging Face Spaces (with Docker option enabled) or any cloud with Docker support.

Hugging Face Space Setup

  • Make sure to enable Docker runtime
  • Add two secrets:
    • HF_TOKEN
    • X-API-KEY