This module of Magnolia CMS provides a tool to fine-tune Large language models like GPT using as input dataset contents in Magnolia CMS.
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>
Activate and configure Open AI or Azure OpenAI
config:/formentor-ai-training/openAI
API key
in the secret openai/api-key
of Password Manager.apiVersion
and url
of the Azure resource and the model to be fine-tuned in configuration of the module.config:/formentor-ai-training/azure
API key
in the secret azure/api-key
of Password Manager.The module ai-training provides the command ModelTrainerCommand
to create fine-tuned models
Input parameters of ModelTrainerCommand
linked fields
specify the target worspace
and target property
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())