Canstralian commited on
Commit
ef67ddd
·
verified ·
1 Parent(s): be0b592

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -86
README.md CHANGED
@@ -9,96 +9,71 @@ 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).
 
9
  pinned: false
10
  ---
11
 
12
+ Here is a sample README.md with GitHub badges:
13
+
14
+ # NLPToolkit Agent - Gradio Chatbot
15
+
16
+ [![Python](https://img.shields.io/badge/python-%3E%3D%203.7-blue)](https://www.python.org/)
17
+ [![Gradio](https://img.shields.io/badge/Gradio-v3.27.0-orange)](https://gradio.app/)
18
+ [![Hugging Face](https://img.shields.io/badge/Hugging%20Face-open--assistant--oasst--sft--4--pythia--12b--epoch--3.5-green)](https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5)
19
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
20
+
21
+ NLPToolkit Agent is a powerful NLP chatbot powered by Hugging Face and Gradio, designed to assist with a variety of NLP tasks including summarization, sentiment analysis, text classification, and entity recognition. It allows users to interact with the model dynamically and adjust parameters like temperature, max tokens, and top-p for better control over the output.
22
+
23
+ ## Features
24
+ - **Multiple NLP Tasks**: Perform tasks like summarization, sentiment analysis, text classification, and entity recognition.
25
+ - **Dynamic Task Selection**: Choose your desired NLP task from a dropdown menu.
26
+ - **Chat History**: Save and load conversation history for reference or further interaction.
27
+ - **Language Detection**: Preprocess user input for language validation and display error messages if the input language is unsupported.
28
+ - **Model Parameters Control**: Fine-tune the model's behavior using sliders for max tokens, temperature, and top-p (nucleus sampling).
29
+ - **Powered by Hugging Face and Gradio**: Utilize state-of-the-art models hosted on Hugging Face with an intuitive Gradio interface.
30
+
31
+ ## Requirements
32
+
33
+ - Python 3.7 or higher
34
+ - Gradio 3.27.0
35
+ - Hugging Face `huggingface_hub` for model inference
36
+ - `langdetect` for language detection
37
+
38
+ Install the dependencies by running:
39
+
40
+ ```bash
 
 
 
 
 
 
 
 
 
 
 
 
41
  pip install -r requirements.txt
42
+ ''''
43
  Usage
44
+ 1. Clone the repository:
45
 
46
+ git clone https://github.com/yourusername/nlptoolkit-agent.git
47
+ cd nlptoolkit-agent
 
 
48
 
49
+ 2. Run the application:
50
 
51
+ python app.py
52
 
53
+ This will start the Gradio interface, which you can access via your browser at http://localhost:7860.
54
+ 3. Interact with the Chatbot:
55
+       •   Select an NLP task (Summarization, Sentiment Analysis, etc.).
56
+       •   Type your message in the input field and click “Generate Response.”
57
+       •   Adjust parameters (max tokens, temperature, top-p) for more fine-tuned responses.
58
+       •   Save and load chat history using the respective buttons.
59
 
60
+ Model Used
61
+
62
+ The application uses the Hugging Face model OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5. You can modify the model to any other compatible model from Hugging Face if desired.
63
+
64
+ License
65
+
66
+ This project is licensed under the MIT License - see the LICENSE file for details.
67
+
68
+ Contributing
69
+
70
+ Feel free to fork this repository and submit pull requests. Contributions are welcome!
71
+
72
+ Acknowledgments
73
+    •   Hugging Face for providing the pre-trained NLP models.
74
+    •   Gradio for the amazing tool to create user interfaces for machine learning models.
75
+    •   OpenAssistant for their contribution to the model.
76
+
77
+ Developed by Canstralian
78
+
79
+ ---