This repository contains code for a BERT REST API that provides various Natural Language Processing (NLP) functionalities using BERT embeddings. The API includes endpoints for obtaining embeddings, performing sentiment analysis, and extracting named entities from input texts.
The project has the following file structure:
bert-rest-api/
├── app/
│ ├── model.py
│ ├── api.py
│ ├── index.html
│ └── requirements.txt
├── Dockerfile
├── .gitignore
├── LICENSE
└── README.md
app/
: Directory containing the main application files.model.py
: Python script defining the BERT model and related functionalities.api.py
: Python script defining the Flask API and its endpoints.index.html
: HTML template for the home page of the API.requirements.txt
: File listing the required Python libraries.
Dockerfile
: File specifying the Docker image configuration..gitignore
: File specifying the patterns of files and directories to be ignored by Git.LICENSE
: File containing the license information for the project.README.md
: File containing the project documentation and instructions.
-
Clone the repository:
git clone https://github.com/abalmumcu/bert-rest-api.git
-
Change to the project directory:
cd bert-rest-api
-
Install the required dependencies:
pip install -r app/requirements.txt
-
Start the API server:
python app/api.py
-
Access the API endpoints:
-
Open your web browser and go to
http://localhost:5000
to view the home page with API information. -
Use an API client (e.g., cURL or Postman) to send POST requests to the desired endpoints mentioned above.
-
To run the API server inside a Docker container, follow these steps:
-
Build the Docker image:
docker build -t bert-rest-api .
-
Run the Docker container:
docker run -d -p 5000:5000 bert-rest-api
-
The API server is now running inside the Docker container. Access
http://localhost:5000
to see the home page and use the API endpoints as mentioned above.
This project is licensed under the MIT License.