Canstralian commited on
Commit
65a82e2
Β·
verified Β·
1 Parent(s): 9131889

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -2
README.md CHANGED
@@ -4,9 +4,101 @@ emoji: πŸ’¬
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
12
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.11.0
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
12
+ NLP Model Deployment with FastAPI
13
+
14
+ [![Build Status](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/actions)
15
+ [![Security Status](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/actions/workflows/security.yml/badge.svg)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/actions)
16
+ [![Dependabot Status](https://img.shields.io/badge/dependabot-active-brightgreen.svg)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/network/updates)
17
+ [![Python Version](https://img.shields.io/badge/python-3.x-blue.svg)](https://www.python.org/)
18
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/blob/main/LICENSE)
19
+ [![Code Coverage](https://img.shields.io/codecov/c/github/Chemically-Motivated-Solutions/NLPToolkit)](https://codecov.io/gh/Chemically-Motivated-Solutions/NLPToolkit)
20
+ [![Downloads](https://img.shields.io/github/downloads/Chemically-Motivated-Solutions/NLPToolkit/total.svg)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/releases)
21
+ [![Issues](https://img.shields.io/github/issues/Chemically-Motivated-Solutions/NLPToolkit)](https://github.com/Chemically-Motivated-Solutions/NLPToolkit/issues)
22
+
23
+ Overview
24
+ This project demonstrates how to deploy Natural Language Processing (NLP) models using FastAPI, a modern web framework for building APIs with Python. The application integrates two pre-trained models from the Hugging Face Transformers library:
25
+
26
+ Sequence Classification Model: Utilized for tasks like sentiment analysis.
27
+ Question Answering Model: Designed to provide answers based on a given context.
28
+ Features
29
+ RESTful API Endpoints:
30
+
31
+ /predict: Accepts user input and returns model predictions.
32
+ /health: Provides health status of the API.
33
+ Model Integration:
34
+
35
+ Incorporates Hugging Face's AutoModelForSequenceClassification and AutoModelForQuestionAnswering for NLP tasks.
36
+ Installation
37
+ Clone the Repository:
38
+
39
+ bash
40
+ Copy code
41
+ git clone https://github.com/yourusername/nlp-fastapi-deployment.git
42
+ cd nlp-fastapi-deployment
43
+ Set Up a Virtual Environment:
44
+
45
+ bash
46
+ Copy code
47
+ python -m venv venv
48
+ source venv/bin/activate # On Windows: venv\Scripts\activate
49
+ Install Dependencies:
50
+
51
+ bash
52
+ Copy code
53
+ pip install -r requirements.txt
54
+ Usage
55
+ Start the FastAPI Server:
56
+
57
+ bash
58
+ Copy code
59
+ uvicorn main:app --reload
60
+ The API will be accessible at http://127.0.0.1:8000.
61
+
62
+ Interact with the API:
63
+
64
+ Navigate to http://127.0.0.1:8000/docs to access the interactive API documentation provided by Swagger UI.
65
+
66
+ **Example Request:**
67
+
68
+ ```bash
69
+ curl -X POST "http://127.0.0.1:8000/predict" -H "Content-Type: application/json" -d '{"text": "Your input text here"}'
70
+ ```
71
+ ## Project Structure
72
+ ```plaintext
73
+ nlp-fastapi-deployment/
74
+ β”œβ”€β”€ app/
75
+ β”‚ β”œβ”€β”€ __init__.py
76
+ β”‚ β”œβ”€β”€ main.py # Main application file
77
+ β”‚ β”œβ”€β”€ models.py # Pydantic models for request and response
78
+ β”‚ β”œβ”€β”€ nlp_models.py # Functions for loading and utilizing NLP models
79
+ β”‚ └── utils.py # Utility functions
80
+ β”œβ”€β”€ requirements.txt # Project dependencies
81
+ β”œβ”€β”€ README.md # Project documentation
82
+ └── .gitignore # Git ignore file
83
+ ```
84
+ ## Dependencies
85
+ - FastAPI: Web framework for building APIs with Python.
86
+ - Transformers: Library for state-of-the-art NLP models.
87
+ - Torch: Deep learning framework used by Transformers.
88
+ - Uvicorn: ASGI server for running FastAPI applications.
89
+
90
+ **Ensure all dependencies are listed in requirements.txt for easy installation.**
91
+
92
+ ## Contributing
93
+ Contributions are welcome! Please fork the repository and submit a pull request with your changes.
94
+
95
+ ## License
96
+ This project is licensed under the MIT License. See the LICENSE file for details.
97
+
98
+ ## Acknowledgements
99
+ - Hugging Face for providing accessible NLP models.
100
+ - FastAPI for the high-performance API framework.
101
+ **For a visual guide on creating a deep learning API with FastAPI, you might find the following resource helpful:**
102
+ https://youtu.be/NrarIs9n24I
103
+
104
+ An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).