Git Product home page Git Product logo

Comments (3)

vimal-m avatar vimal-m commented on June 16, 2024

Thank you for highlighting the missing piece of documentation in our docs. The documentation is work-in-progress and would be updated on the doc site soon.

Acharya mainly interacts with 3 config files to initiate training and evaluation of any 3rd party algorithms. These are

  1. Algorithm configuration - The yaml config added in the algorithm section of the Project.
  2. Config.Yaml - The yaml config inside the algorithm repo which defines how to run the training and how to evaluate the trained models.
  3. Dockerfile - The Dockerfile of the algorithm inside the repo with which Acharya builds the docker container to train and evaluate the algorithm.

The Algorithm Configuration is added to a Project Under Algorithms via the UI, the Config.yaml and Dockerfile are accessed from the algorithm code repository.

I will explain with an example how to train a spacy model in Acharya (training other algorithms is almost similar).

This example can be accessed at https://github.com/astutic/acharya-spacy/tree/setup. This is the setup branch which has code for Cuda training of spacy.

First, we need to create a Dockerfile to ensure training and test/eval can be done within a docker container. The Dockerfile would be specific to the system you are running the training on. e.g. If I am planning to run spacy on a system with Cuda 11.4.2 my docker file would look like

FROM nvidia/cuda:11.4.2-devel-ubuntu20.04

RUN apt-get update && apt-get install -y gcc musl-dev g++
RUN apt-get install -y python3 python3-dev python3-pip

COPY requirements.txt /

RUN pip3 install -r /requirements.txt

WORKDIR /root
COPY config.yaml .

#Copy all source code required for training and test
#anything else 

Here the requirements.txt carry the pip packages required for my source code to run. An example would be

cupy-cuda114
spacy[cuda114]

Notice the config.yaml copied into the docker container. This config file helps Acharya decide how to train and test/evaluate the model and how to send the data for training and evaluation. e.g.

title: Spacy Algo config for Acharya
owner: Astutic AI
author: VM
train:
        cmd: /usr/bin/sh train.sh
        type: cmd
        input: data/trainfile.conll
        output: stdout
eval:
        cmd: python3 evaluate_model.py
        type: service
        input: "tcp::5566"
        output: "tcp::5566"

Here this config tells Acharya that the training should be done by invoking the train.sh shell script and this script would read the training data from the file specified and would output any relevant information over stdout. The current version of Acharya does not process the output but shows it in UI.
Similarly, the eval section tells Acharya how to evaluate a single record. In the config file, the evaluation script is defined as a service/daemon and it communicates over tcp port 5566.

Acharya in the current version only supports the same data format for Input and Output which can be defined in the Algorithm Configuration. (For eg: If the data format defined in the Algorithm configuration is IOB then Acharya would send the training and evaluation data in IOB format and would also expect the output of evaluation to be in IOB format.)

The Algorithm Configuration with which we can train this model is

Name: Spacy v3 Cuda
Version: 1.0
Owner: Astutic AI
DataFormat: CoNLL2003
RunOn: Docker
Details:
  Image: False
  Port: 7707/tcp # 22/TCP 
  HostIP: 0.0.0.0
  Debug: True
  DockerHost: localhost
  DockerHostPort: 2375
  Runtime: nvidia
AlgoFrom: Git #(local/remote)
AlgoDetails:
  Path: https://github.com/astutic/acharya-spacy.git
  Branch: setup
  Auth: None #(http/ssh/None)
  DockerfilePath: Dockerfile
  ConfigPath: config.yaml
  AlgoOutput:
    - /models
  RestoreOutput: True
  Logs:
    - /root/parse_ner.log

In this configuration the DataFormat is defined as CoNLL2003, Acharya would send the data to the training and evaluation in CoNLL2003 and would expect the same as the evaluation output.

DockerfilePath is the path to the Dockerfile inside the repository. Similarly, ConfigPath is the path to the training and evaluation yaml config inside the repository.

You can add multiple file/folder under AlgoOutput and these would be saved as artifacts after the training and can be accessed from the Acharya UI.

To train the Algorithm in Acharya, Add the above algorithm config under Algorithms in a Project from the UI and then access Training and New Training.

Acharya would pull the repo and the branch specified, create the docker container and run the train and eval commands as mentioned in the config.yaml

In some cases one might not want to train but rather just evaluate a 3rd party model downloaded from the internet, a similar example can be found in the PreModelEval branch of the same repository.
Here the train.sh is only downloading the model and no training is actually happening.
To test this, the Algorithm configuration for the same is here https://github.com/astutic/acharya-spacy/blob/PreModelEval/algo_configuration.yaml

Note
The evaluate_model.py entity mapping code is hardcoded for CoNLL2003 dataset, feel free to experiment.

Acharya can also do WordEmbeddings training before the actual training and these are initiated only when the dataset changes. The training and eval documentation I am creating would explain them in detail.

There has been a bug fixed and a hotfix released in relation to docker container creation, please download the hotfix available here https://github.com/astutic/Acharya/releases/tag/v0.3.1-alpha.hotfix

from acharya.

vimal-m avatar vimal-m commented on June 16, 2024

For this version, please set useCache to false in the Admin Settings https://acharya.astutic.com/docs/tutorial-basics/admin-settings

from acharya.

vimal-m avatar vimal-m commented on June 16, 2024

A demo of training the model and using it for annotation can be seen here https://www.youtube.com/watch?v=s0EI8_AJ7zo

from acharya.

Related Issues (2)

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.