This module of Magnolia CMS provides a tool to fine-tune Large language models like GPT using as input dataset contents in Magnolia CMS.
- Integration with the API of OpenAI and Azure OpenAI
- Export of contents in Magnolia to datasets for fine-tuning models of Open AI and Azure OpenAI
- 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
- Specify host of OpenAI and model to fine-tuned in the configuration of the module.
config:/formentor-ai-training/openAI
- Specify
API key
in the secretopenai/api-key
of Password Manager.
- Specify
apiVersion
andurl
of the Azure resource and the model to be fine-tuned in configuration of the module.
config:/formentor-ai-training/azure
- Specify the
API key
in the secretazure/api-key
of Password Manager.
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 thetarget worspace
andtarget property
- propertyAsCompletion to specify the property used as completion in the examples of the training data.
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())