Giter VIP home page Giter VIP logo

comment-generator's Introduction

ML based Comment Generation

Machine learning pipeline for end-to-end Text Classification, Named-Entity Recognition and Comments Generation.


Installation

Required python version: 3.7 or higher and MongoDB

git clone https://github.com/highplainscomputing/comment-generator.git
cd comment-generator
pip install -r requirements.txt

Docker setup

1. Clone repository:

git clone https://github.com/highplainscomputing/comment-generator.git

2. Build docker:

cd comment-generator
docker build --tag comment-generator:latest .

3. Run docker server:

docker run -d -p 8080:8080 comment-generator:latest

4. Use Docker Compose: It will create both the images (mongoDB and fastAPI) and start the containers.

docker-compose up -d

Server API usage

Start server

uvicorn run_server:app --host "0.0.0.0" --port 8000

For Visualizing application Visit: http://localhost:8000/docs

Endpoints

  • /health endpoint for checking server availability.

  • /generate endpoint for running complete pipeline and saving the result as json in MongoDB. Example input text:

    A Christmas tree that can receive text messages has been unveiled at London's Tate Britain art gallery.
    The spruce has an antenna which can receive Bluetooth texts sent by visitors to the Tate. The messages 
    will be "unwrapped" by sculptor Richard Wentworth, who is responsible for decorating the tree with broken 
    plates and light bulbs. It is the 17th year that the gallery has invited an artist to dress their Christmas
    tree. Artists who have decorated the Tate tree in previous years include Tracey Emin in 2002.
    

    Example Output

  • {
    "entities":['NAME':'SIBTAIN RAZA'],
    "category": "politics"
    }
    
  • /view endpoint for Viewing list of stored results which include text category, ner and generated comment.

  • Example outputs:

    [{
    "id": "614a7804be790f5ae9de0e8b",
    "category": "politics",
    "entities": {
      "ORG": [
        "Sibtain Raza",
        "taliban"
      ]
    },
    "comment": "Sibtain Raza is a ML Engineer."}]
    

Local usage (for debugging purposes)

Example of Running Pipeline on input text:

python main.py --input_text 'put your text here' --config config.yaml

Run tests

cd comment-generator
pytest .

Configuration and file structure

Project file structure is:

.
├── comment_generator
│    ├── __init__.py
│    ├── pipeline.py
│    ├── models
│    │    ├── __init__.py
│    │    ├── base.py
│    │    ├── classifier.py
│    │    └── generator.py
│    │    ├── ner.py
│    ├── utils
│    │    ├── __init__.py
│    │    ├── db_utils.py
│    │    ├── fastapi_models.py
│    │    └── parse_config.py
├── test
│   ├──__init__.py
│   ├──test_parse_config.py
│
└── docker-compose.yml
└── Dockerfile
└── config.yaml
└── README.md
└── main.py
└── run_server.py
└── requirements.txt

Contributer

Sibtain Raza

comment-generator's People

Contributors

sibtainrazahpc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.