All Projects → ahmedbesbes → anonymization-api

ahmedbesbes / anonymization-api

Licence: other
How to build and deploy an anonymization API with FastAPI

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to anonymization-api

Spacy Streamlit
👑 spaCy building blocks and visualizers for Streamlit apps
Stars: ✭ 360 (+605.88%)
Mutual labels:  spacy, named-entity-recognition, ner
NER-and-Linking-of-Ancient-and-Historic-Places
An NER tool for ancient place names based on Pleiades and Spacy.
Stars: ✭ 26 (-49.02%)
Mutual labels:  spacy, named-entity-recognition, ner
Spacy Lookup
Named Entity Recognition based on dictionaries
Stars: ✭ 212 (+315.69%)
Mutual labels:  spacy, named-entity-recognition, ner
presidio-research
This package features data-science related tasks for developing new recognizers for Presidio. It is used for the evaluation of the entire system, as well as for evaluating specific PII recognizers or PII detection models.
Stars: ✭ 62 (+21.57%)
Mutual labels:  spacy, named-entity-recognition, ner
Spacy Course
👩‍🏫 Advanced NLP with spaCy: A free online course
Stars: ✭ 1,920 (+3664.71%)
Mutual labels:  spacy, named-entity-recognition
Ner Annotator
Named Entity Recognition (NER) Annotation tool for SpaCy. Generates Traning Data as a JSON which can be readily used.
Stars: ✭ 127 (+149.02%)
Mutual labels:  spacy, ner
KoBERT-NER
NER Task with KoBERT (with Naver NLP Challenge dataset)
Stars: ✭ 76 (+49.02%)
Mutual labels:  named-entity-recognition, ner
PhoNER COVID19
COVID-19 Named Entity Recognition for Vietnamese (NAACL 2021)
Stars: ✭ 55 (+7.84%)
Mutual labels:  named-entity-recognition, ner
neural name tagging
Code for "Reliability-aware Dynamic Feature Composition for Name Tagging" (ACL2019)
Stars: ✭ 39 (-23.53%)
Mutual labels:  named-entity-recognition, ner
extractacy
Spacy pipeline object for extracting values that correspond to a named entity (e.g., birth dates, account numbers, laboratory results)
Stars: ✭ 47 (-7.84%)
Mutual labels:  spacy, ner
scikitcrf NER
Python library for custom entity recognition using Sklearn CRF
Stars: ✭ 17 (-66.67%)
Mutual labels:  named-entity-recognition, ner
Spacy
💫 Industrial-strength Natural Language Processing (NLP) in Python
Stars: ✭ 21,978 (+42994.12%)
Mutual labels:  spacy, named-entity-recognition
SynLSTM-for-NER
Code and models for the paper titled "Better Feature Integration for Named Entity Recognition", NAACL 2021.
Stars: ✭ 26 (-49.02%)
Mutual labels:  named-entity-recognition, ner
molminer
Python library and command-line tool for extracting compounds from scientific literature. Written in Python.
Stars: ✭ 38 (-25.49%)
Mutual labels:  named-entity-recognition, ner
weak-supervision-for-NER
Framework to learn Named Entity Recognition models without labelled data using weak supervision.
Stars: ✭ 114 (+123.53%)
Mutual labels:  spacy, named-entity-recognition
nlp-cheat-sheet-python
NLP Cheat Sheet, Python, spacy, LexNPL, NLTK, tokenization, stemming, sentence detection, named entity recognition
Stars: ✭ 69 (+35.29%)
Mutual labels:  spacy, named-entity-recognition
anonymisation
Anonymization of legal cases (Fr) based on Flair embeddings
Stars: ✭ 85 (+66.67%)
Mutual labels:  spacy, ner
spacy-server
🦜 Containerized HTTP API for industrial-strength NLP via spaCy and sense2vec
Stars: ✭ 58 (+13.73%)
Mutual labels:  spacy, named-entity-recognition
TweebankNLP
[LREC 2022] An off-the-shelf pre-trained Tweet NLP Toolkit (NER, tokenization, lemmatization, POS tagging, dependency parsing) + Tweebank-NER dataset
Stars: ✭ 84 (+64.71%)
Mutual labels:  named-entity-recognition, ner
SkillNER
A (smart) rule based NLP module to extract job skills from text
Stars: ✭ 69 (+35.29%)
Mutual labels:  spacy, ner

Deploy an inference API on AWS (EC2) using FastAPI Docker and Github Actions

To learn more about this project: medium blog post

The goal of this project is to streamline the process of building and deploying an inference API on AWS using Docker and Github actions.

The API's goal is to anonymize text data by detecting named entities (names, organizations, locations) and returning an anonymized text.

Here's a highlevel overview of the API.

1- Develop the app locally

The API route is defined in api/main.py

A Dockerfile is defined to create an image for this API: pretty standard.

A docker-compose to manage services between others (as for now, there's only one service: the API)

2- Launch an EC2 instance

Connect to your AWS account, go the EC2 section and pick a distribution. I recommend Ubuntu 20.04 LTS for this tutorial.

Pick an instance: we're not gonna go crazy here. We'll just pick a relatively small one: a t2.medium.

I changed the default storage to 30GB but you can leave it to 8GB (default value)

Now launch the instance.

Create an elastic IP address and associate it to the running instance. This way this IP won't change everytime the we restart the instance.

Add a new security group (I named it fastapi) to allow inbound traffic on port 8000.

Then add to the instance security groups:

Now the instance is ready to accept requests.

3- SSH to the instance and configure it

SSH into the instance using your terminal.

  • Install docker and docker-compose by following the official Docker documentation

  • Generate an ssh key and add it to your Github account so that it can perform git clones seamlessly

4- Configure a Gihub Actions workflow

1- Go to your repo and click on the Actions tab

  1. Click on setup a workflow yourself

  1. Define your workflow

A YAML file will be automatically created inside a workflows folder which will be itself created in a .github folder at the root of the repo.

The workflow will be triggered on push requests only (on the main branch)

The job that will be triggered will be run on a remote server that Github Actions will connect to through the SSH Remote Commands custom Github Action that you can find from the marketplace.

The SSH Remote Commands Github Action will be called with the following arguments

  • host: the hostname of the server (i.e. its public IP)
  • username: the ssh username
  • key: the content of ssh private key
  • script: the script that will be executed once the ssh connection is established

The script will list the commands that will be run on the server once the SSH connection is established: it'll clone the repo, cd into it and run the docker-compose build and up commands.

git clone [email protected]:ahmedbesbes/anonymization-api.git
cd anonymization-api
sudo docker-compose build
sudo docker-compose up -d
  1. Define Github secrets

The previous arguments host, username and key will not be hard-coded in the YAML file.

They will rather be stored as Github secrets and referenced with the $ sign, the same way you would call environment variables.

To create Github secrets, go to the settings of the repository and click on Secrets on the left tab.

Then define your secrets by giving setting their name (in capital letters) and their value.

Here's how you would set the USERNAME secret for example.

  1. Commit, push and look out for the magic happening

Once you push your code (after testing that everything works fine locally) you will notice a new run queued to start.

By clicking on it, you can see the different steps of the build.

  1. Check that everything is working

Once the API is successfully deployed on your remote server, fire up Postman and execute some requests on the API endpoint.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].