Skip to content

formentor-studio/magnolia-ai-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magnolia AI Training

This module of Magnolia CMS provides a tool to fine-tune Large language models like GPT using as input dataset contents in Magnolia CMS.

Features

Setup

  1. Add maven dependency to your bundle of Magnolia
<dependencies>
    <dependency>
        <groupId>org.formentor</groupId>
        <artifactId>magnolia-ai-training</artifactId>
        <version>0.0.1</version>
    </dependency>
</dependencies>
  1. Activate and configure Open AI or Azure OpenAI

OpenAI

  • Specify host of OpenAI and model to fine-tuned in the configuration of the module.

config:/formentor-ai-training/openAI

open-ai-magnolia

openai-api-key

Azure OpenAI

  • Specify apiVersion and url of the Azure resource and the model to be fine-tuned in configuration of the module.

config:/formentor-ai-training/azure

azure-magnolia

azure-openai-api-key

Usage

The module ai-training provides the command ModelTrainerCommand to create fine-tuned models

Input parameters of ModelTrainerCommand

  • modelName to specify the prefix of the fine-tuned model created.
  • workspace to specify the workspace of the text contents to be used to build the training data for fine-tuning.
  • root to specify the root path of the nodes to be used to build the examples of the datataset.
  • nodeType to specify of the node type of the nodes to be used to build the training data.
  • propertiesAsPrompt to specify the properties to be used to build the prompt in the training data. In case of linked fields specify the target worspace and target property
  • propertyAsCompletion to specify the property used as completion in the examples of the training data.

Example

cm = info.magnolia.commands.CommandsManager.getInstance()
command = cm.getCommand('formentor','FineTuneModelCommand')

/**
 *
 * This example fine-tunes the model using as dataset:
 * INPUT: properties "tourTypes", "category" and "displayName" of nodtypes "mgnl:content" in the workspace "tours" from path "/magnolia-travels" 
 * COMPLETION: property "body"
 *
 * The fine-tuned model will be trained for the task of writing description of tours from the factsheet
 */
propertyPromptTourTypes = new com.formentor.magnolia.ai.training.domain.PropertyPromptValue()
propertyPromptTourTypes.setPropertyName('tourTypes')
reference = new com.formentor.magnolia.ai.training.domain.PropertyPromptValue.Reference()
reference.setTargetWorkspace("category")
reference.setTargetPropertyName("displayName")
propertyPromptTourTypes.setReference(reference)

propertyPromptLocation = new com.formentor.magnolia.ai.training.domain.PropertyPromptValue()
propertyPromptLocation.setPropertyName('location')

command.setWorkspace('tours')
command.setModelName('magnolia-tours')
command.setRoot('/magnolia-travels')
command.setNodeType('mgnl:content')
command.setPropertiesAsPrompt([propertyPromptTourTypes, propertyPromptLocation])
command.setPropertyAsCompletion(['body'])

command.execute(new info.magnolia.context.SimpleContext())

About

Fine tuning of LLM models using contents in Magnolia CMS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages