Skip to content

geehaad/LLamaIndex-text-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

G-Text Classifier using LLamaIndex and Gradio📋

Welcome to G-Text Classifier, a powerful tool for classifying text based on user-defined labels. Make text classification a breeze! 😎

Table of Contents

  • Overview
  • Features
  • Getting Started
  • Usage
  • Contributing

Overview

G-Text Classifier is a user-friendly application that takes a piece of text or a file and classifies it based on the label provided by the user. Whether you're analyzing sentiment, categorizing documents, or any other text classification task, this tool has you covered.
Here we used GPT from LlamaIndex beside Gradio open-source Python package to build fast UI components.

Interface 🎨

Code Structure

The project is organized as follows:

Text_classification/
|-- data/: This directory contains the data used for text classification.
| |-- Reviews.csv: Sample CSV data for classification (if applicable).
| |-- reviews.txt: Sample text data for classification (if applicable).

|-- prototype/: This directory holds the prototype code. | |--webApp.py: The main Python script for the Gradio web application.

|-- src/: This directory contains the project source code. | |-- components/: Subdirectory with essential components for text classification. | | |-- init.py: Initialization file for the components directory. | | |-- helper.py: Helper functions for text classification.

|-- storage/: This directory stores the output of indexing the data for efficient classification. | |-- docstore.json: Document store file. | |-- graph_store.json: Graph store file. | |-- index_store.json: Index store file. | |-- vector_store.json: Vector store file.

|-- README.md: This file, providing an overview of the project and its structure.

Features

✨ Text Classifier comes with the following features:

📄 Text Classification: Enter plain text along with a label and get instant classification results. 📁 File Upload: Upload text files for batch classification. 🌟 User-Friendly Interface: Built with Gradio for an intuitive and interactive user experience.

Getting Started

👨‍💻 To get started with Text Classifier, follow these simple steps:

  1. Clone the repository:
    git clone https://github.com/geehaad/LLamaIndex-Text-Classification.git
    cd LLamaIndex-Text-Classification
  2. Install the required dependencies:
    pip install -r requirements.txt
  3. Start the application (you can run the helper file to get the output in your terminal, or use the interface):
    python helper.py
    python prototype/webApp.py
  4. Access the application in your browser at http://localhost:5000. (the linke will appear in your terminal)

Usage

🚀 Using the Text Classifier with Gradio is easy and user-friendly. You have two options:

Text Classification

  1. Select the "Text" tab to classify individual text entries.
  2. Enter the text in the "context" textbox.
  3. Specify how you want to classify it in the "Labels" textbox.
  4. Click "Get Classification" to see the result.

File Classification

  1. Select the "Files" tab to classify text from a file.
  2. Upload a text file using the "context" file input.
  3. Specify the classification labels in the "Labels" textbox.
  4. Click "Get Classification" to process the file and view the results.

Helper File (helper.py)

The helper.py file in the src/components directory contains the essential functions for text classification. It uses OpenAI's GPT model for classification.

Here's a brief overview of the helper functions:

analyze_file(file_path, labels): Classifies text from a file based on provided labels.
analyze_text(text, labels): Classifies a single text entry based on provided labels.

To use the helper functions, ensure that your OpenAI API key is set correctly in helper.py.

Contributing

🤝 We welcome contributions from the community to make Text Classifier even better. If you'd like to contribute, please follow these guidelines:
  • Fork the repository.
  • Create a new branch:
    git checkout -b feature/your-feature-name. 
  • Make your changes and commit them:
    git commit -m 'Add some feature'.
  • Push to your branch:
    git push origin feature/your-feature-name.
  • Create a pull request.

Start classifying text like a pro with Text Classifier. Whether it's sentiment analysis, document categorization, or any other text classification task, we've got you covered. If you have any questions or suggestions, feel free to reach out. Happy classifying! 📋🚀

To know more about LlamaIndex: llamaindex.ai

About

Text Classification using LlamaIndex and Gradio

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages