Skip to content

Cerberus is a modular, containerized AI solution offering sentiment analysis, text summarization, and text generation APIs using fine-tuned and quantized Hugging Face models. Designed for efficiency and scalability, it enables seamless integration into workflows, ensuring high performance, low latency, and flexibility for developers and businesses

License

Notifications You must be signed in to change notification settings

BonnardValentin/cerberus

Repository files navigation

Cerberus

Cerberus is a modular, containerized AI solution offering APIs for sentiment analysis, text summarization, and text generation. Built on top of fine-tuned and quantized Hugging Face models, Cerberus is designed for scalability, efficiency, and easy integration into workflows.


Features

  • Sentiment Analysis: Quickly classify text sentiment as positive, negative, or neutral.
  • Summarization: Generate concise and meaningful summaries for long text.
  • Text Generation: Produce creative or structured text based on input prompts.
  • Scalable Architecture: Deployed using containerized services for easy scaling.
  • Optimized Models: Uses fine-tuned and quantized Hugging Face models for speed and accuracy.
  • OpenAPI Documentation: Built-in API documentation for developers.
  • Extensible: Easily add new AI models and services.

Technologies Used

  • Programming Language: Python 3.10+
  • Frameworks: FastAPI for API development
  • AI Models: Hugging Face (Transformers, Optimum, Accelerate)
  • Machine Learning Backend: PyTorch with MPS support for macOS (Apple Silicon)
  • Data Handling: Datasets library by Hugging Face
  • Deployment:
    • Docker for containerization
    • Docker Compose for service orchestration

Table of Contents


Getting Started

Prerequisites

  • Python 3.10 or higher

  • Poetry for dependency management:

    curl -sSL https://install.python-poetry.org | python3 -
  • Docker and Docker Compose installed: Docker Installation Guide

Installation

  1. Clone the Repository:

    git clone https://github.com/BonnardValentin/cerberus
    cd cerberus
  2. Install Dependencies with Poetry:

    poetry install
  3. Set Up Environment Variables: Create a .env file in the project root with the following:

    MODEL_PATH="./models/quantized"
    API_KEY="your-secret-key"
    
  4. Start the Application: Using Docker Compose:

    docker-compose up --build
  5. Test the Application: Access the API at http://localhost:8000.


Usage

Endpoints

  • Sentiment Analysis: /analyze-sentiment/
  • Summarization: /summarize/
  • Text Generation: /generate-text/

Example Requests

Sentiment Analysis

curl -X POST http://localhost:8000/analyze-sentiment/ \
-H "Content-Type: application/json" \
-d '{"text": "I love Cerberus!"}'

Summarization

curl -X POST http://localhost:8000/summarize/ \
-H "Content-Type: application/json" \
-d '{"text": "Docker simplifies containerization by providing a platform to develop, ship, and run applications in isolated environments."}'

Text Generation

curl -X POST http://localhost:8000/generate-text/ \
-H "Content-Type: application/json" \
-d '{"text": "Once upon a time, in a faraway land,"}'

API Documentation

Cerberus provides an interactive OpenAPI UI:


Development

Run Locally Without Docker

  1. Activate the Poetry environment:

    poetry env activate
  2. Start the FastAPI server:

    uvicorn app.main:app --reload

Test the Models

Run a Python script to verify that models are loaded correctly:

from transformers import pipeline

model = pipeline("sentiment-analysis", model="./models/quantized")
print(model("I love open-source!"))

Contributing

We welcome contributions to Cerberus! To contribute:

  1. Fork the repository.

  2. Create a feature branch:

    git checkout -b feature-name
  3. Commit your changes:

    git commit -m "Add new feature"
  4. Push to your fork:

    git push origin feature-name
  5. Open a pull request.

Please read our Contributing Guide for more details.


License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Cerberus is a modular, containerized AI solution offering sentiment analysis, text summarization, and text generation APIs using fine-tuned and quantized Hugging Face models. Designed for efficiency and scalability, it enables seamless integration into workflows, ensuring high performance, low latency, and flexibility for developers and businesses

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published