Start

27/08/2025

Close

Movie Reviews Sentiment Analysis Challenge

Classify positive and negative reviews

Challenge Rewards:

knowledge

Participants

150

Submissions

142

Movie Reviews Model

License Python System

Code instructions: Instructions for creating code to submit for the Movie Reviews Sentiment Analysis challenge.

Table of Contents

Quick Start

Download code baseline.

# 1. Install dependencies (Do not add any other libraries to requirments.txt file)
pip install -r requirements.txt

# 2. Start developing your solution. Follow the tutorial below to implement your AI model

# 3. Run demo to test implement
python demo.py

Note: You need to implement your movie reviews solution following the tutorial guide.

Introduction

The Movie Reviews Model Challenge is a beginner-friendly introduction to machine learning, teaching you how to classify movie reviews. It’s the perfect hands-on way to master text analysis and build your first NLP model!

AIOZ Movie Reviews Challenge

In this challenge, participants will be provided with:

  • Model Access: movie_reviews_model.
    • Code baseline to develop solutions
    • Predefined libraries and tools in requirements.txt (Do not add any other libraries to requirments.txt file)
  • Dataset Access: movie_reviews_data.
    • Training dataset to train your AI models
    • Testing dataset to predict labels for generating the submission file

Goal: It is your job to classify the movie reviews is positive or negative.

Requirements

System Requirements

  • Python 3.10+

Dependencies

Install all required packages:

pip install -r requirements.txt

Project Structure

Your AI library should follow this structure:

repository/
├── my_ai_lib/                   # Your AI library
│   ├── __init__.py              # Required: Library initialization
│   ├── run.py                   # Required: Main workflow function
│   ├── predict_submission.py    # Required: Generate predictions for challenge submission.
│   └── [your_modules]/          # Your custom modules
├── models/                      # Model weights directory
├── demo.py                      # Demo script
├── requirements.txt             # Dependencies
└── README.md                    # Documentation

Description

  • The input and output of the AI model are defined in my_ai_lib/run.py.
  • The AI model is designed to process a single input item.
  • In my_ai_lib/predict_submission.py, we process all items in the test dataset and save the results to result.csv in the required submission format.
  • Please refer to the instructions below for more details.

Key Components

ComponentDescriptionStatus
my_ai_lib/Core AI library directoryRequired
my_ai_lib/__init__.pyLibrary initializationRequired
my_ai_lib/predict_submission.pyGenerate predictions for challenge submission.Required
my_ai_lib/run.pyMain AI workflowRequired
demo.pyDemo and testing scriptRequired

Detailed Tutorial

Step 1: Initialize Your AI Library

1.1 Define my_ai_lib/__init__.py

from .run import run

This file defines that the run() function in run.py as an attribute of the my_ai_lib and that I can call it by my_ai_lib.run()

1.2 Define Input/Output Objects in my_ai_lib/run.py

Create your custom input and output classes:

from pathlib import Path
from typing import Any, Union, Literal
from aioz_ainode_adapter.schemas import InputObject, OutputObject, FileObject


class MyInput(InputObject):
    input_image: str
    example_param: Any


class MyOutput(OutputObject):
    text: str
    output_image: FileObject

Step 2: Understanding AIOZ Schema Objects

The aioz_ainode_adapter library defines 3 core object types based on pydantic.BaseModel:

🔸 InputObject

Define the format for input when the AIOZ-AI-Node system sends to your AI library.

Default Parameters:

ParameterTypeDescription
deviceChoiceDevice for your model: ["cuda", "cpu"]
model_storage_directoryStringDirectory containing model weights

Important : Always use model_storage_directory for model weight paths, as AIOZ-AI-Node will specify this location.

🔸 OutputObject

Define the format for output when your AI library sends to the AIOZ-AI-Node system.

🔸 FileObject

Define the format for the file, if your output has a file. This object has two fields:

FieldTypeDescription
dataChoiceFile data: io.BufferedReader, Path, or URL
nameStringFile name

Example FileObject creation:

output_file = FileObject(data=open("file/path.csv", "rb"), name="output.csv")

Note:

  • If your input param have a file, it must be a local file path or URL
  • If your output has a file, it must be a FileObject

Step 3: Implement the Main Workflow

3.1 Define Your AI Task Function

def do_ai_task(
        input_image: Union[str, Path],
        example_param: Any,
        model_storage_directory: Union[str, Path],
        device: Literal["cpu", "cuda"] = "cpu",
        *args, **kwargs) -> Any:
    """
    Define AI task: load model, pre-process, post-process, etc.
    
    Args:
        input_image: Path to input image
        example_param: Example parameter
        model_storage_directory: Directory containing model weights
        device:
        
    Returns:
        Result
    """
    # Define your AI task workflow. Below is an example
    text = "This is the AI task result"
    output_image = open("wiki/aioz.png", "rb")  # io.BufferedReader
    return text, output_image

3.2 Implement the Required run() Function

def run(input_obj: InputObject) -> OutputObject:
    """
    Main entry point for your AI library.
    
    Args:
        input_obj: Input object containing all parameters
        
    Returns:
        OutputObject: Results of AI processing
    """
    # Validate and parse input
    my_input = MyInput.model_validate(input_obj.model_dump())
    print(f"Input: {my_input}")

    # Execute AI task
    text, output_image = do_ai_task(
        input_image=my_input.input_image,
        example_param=my_input.example_param,
        model_storage_directory=my_input.model_storage_directory,
        device=my_input.device
    )

    # Create output object
    output_file = FileObject(data=output_image, name="output_image.png")
    output_obj = MyOutput(text=text, output_image=output_file)
    return output_obj

Critical: The run() function name is mandatory and cannot be changed. The do_ai_task() function can be renamed and customized.

Step 4: Create Demo Script

Create demo.py to test your implementation:

import my_ai_lib
from aioz_ainode_adapter.schemas import InputObject


def main():
    """Demo function to test your AI library."""
    input_obj = InputObject(
        input_image="wiki/aioz.png", 
        example_param="example"
    )
    output_obj = my_ai_lib.run(input_obj)
    print(f"Output: {output_obj}")


if __name__ == '__main__':
    main()

The my_ai_lib.run() function receives an InputObject and returns an OutputObject.

Expected console output:

Input: type='InputObj' device='cuda' model_storage_directory='models' input_image='wiki/aioz.png' example_param='example'
Output: type='OutputObj' text='This is the AI task result' output_image=FileObject(type='FileObj', data=<_io.BufferedReader name='wiki/aioz.png'>, name='output_image.png')

Step 5: Add Model Weights

Place your trained model files in the models/ directory:

models/
├── model.pth          # Your trained model
├── config.json        # Model configuration
└── etc.

Step 6: Create Prediction Script (For Submission)

Implement the predict_submission() function in my_ai_lib/predict_submission.py:

Requirements:

  • Function accepting test data folder path (string)
  • Load your trained model
  • Process test dataset (test.csv in test data folder)
  • Generate predictions
  • Save results as ./result.csv

Implementation Template:

from aioz_ainode_adapter.schemas import InputObject
import my_ai_lib
def predict_submission(test_data_folder: str):
    """
    Generate predictions for challenge submission.
    
    Args:
        test_data_folder: Path to test data directory
    """
    # Load your model
    # Process test data
    # Generate predictions
    # Save to ./result.csv

    # Example:
    # Find test data (test.csv) in test data folder (using os.walk)
    # Loop with each review:
    # - You define InputObject
    #     input_obj = InputObject(
    #     input_text=str(review), 
    # )
    # - Output (sentiment is predicted from your model): output = my_ai_lib.run(input_obj)
    # - Write the predicted sentiment (output.text) to result.csv
    pass


def main():
    """Main function for testing submission."""
    predict_submission("path/to/test/data")


if __name__ == '__main__':
    main()

Important: The result.csv must match the challenge's sample submission format.

Verify Your Submission:

python -m my_ai_lib.predict_submission

Submission Guidelines

Submission format

The submission file has two field:

  • review_index: The unique identifier/index corresponding to each review
  • sentiment: The predicted sentiment associated with the review

Example:

	review_index, sentiment
	12345,negative
	12346,positive

License

This repository is licensed under the MIT License.