codeforpakistan / YDF

Utilizing Language Model to Detect Discrimination in PDF Documents across Various Communities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discrimination Detection API with OpenAI GPT-3

Table of Contents

Description

This project is a Flask-based API that utilizes the OpenAI GPT-3 language model to detect discrimination in PDF documents across various communities. Discrimination detection is a crucial task for promoting fairness and equality. The API allows users to upload PDF documents, extracts text from them, and analyzes the text using GPT-3 to determine the presence of discrimination.

Features

  • Accepts PDF files as input.
  • Uses the OpenAI GPT-3 (gpt-3.5-turbo) language model for discrimination detection.
  • Provides discrimination detection results for various communities.

Getting Started

Prerequisites

Before running the project, ensure you have the following prerequisites installed:

  • Python 3.x
  • Flask
  • OpenAI Python Library
  • A valid OpenAI API key (obtain from the OpenAI website)

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/codeforpakistan/YDF.git
  2. Install the required Python libraries:

    pip install -r requirements.txt
  3. Set your OpenAI API key:

    Create a .env file with the following variable

    OPENAI_API_KEY=****
    

Usage

To use the API:

  1. Start the Flask application:

    python app.py
  2. Access the API via a web browser or API client.

Endpoints

  • GET /: Provides a web interface for uploading PDF files.
  • POST /upload: Accepts a PDF file, extracts text, and analyzes it for discrimination using the OpenAI GPT-3 model.

Example

To detect discrimination in a PDF document, use the /upload endpoint with a PDF file:

  1. Upload a PDF document through the web interface.
  2. Submit the form to analyze the document.
  3. The API will return the result: "Discrimination detected" or "No discrimination detected."

Configuration

You can configure the API behavior by modifying the app.py file. You can adjust parameters like the GPT-3 model used, prompt, and response handling.

Deployment

Deploy your Flask application to a web server or a cloud platform for production use. Ensure that your server environment meets the prerequisites and installation requirements mentioned above.

Contributing

Contributions to this project are welcome. If you have any suggestions, bug reports, or feature requests, please open an issue or create a pull request.

About

Utilizing Language Model to Detect Discrimination in PDF Documents across Various Communities.


Languages

Language:Python 93.1%Language:HTML 6.9%