Hi Carina,
here's the requested information:
1) Sample of training data:
See attached sample.json
**2) AdapterTrainingConfiguration **
config3 = AdapterTrainingConfiguration(
epochs=6,
learning_rate=1e-4,
batch_size=2, # Try increasing if memory allows
gradient_accumulation_steps=4, # Reduce accordingly
enable_activation_checkpointing=True,
precision='bf16-mixed',
max_sequence_length=4095,
compile_model=False
)
train_adapter(
train_data=TRAIN_FILE,
eval_data=VALID_FILE,
config=config3,
checkpoint_dir='/content/drive/MyDrive/checkpoints'
)
3) at inference time (from my unit tests)
https://github.com/MAOShea/Hello-World-Tools-Adapter-SwiftUI/blob/main/Hello%20World%20ToolsTests/LanguageModelComparisonTests.swift
struct SessionFactory {
static func createSession(
modelType: ModelType,
systemPrompt: SystemPromptVersion
) throws -> LanguageModelSession {
let tools = [WriteUbersichtWidgetToFileSystem()]
switch modelType {
case .base:
let instructions = systemPrompt.prompt
return LanguageModelSession(
tools: tools,
instructions: instructions
)
case .adapter(let adapterURL):
let adapter = try SystemLanguageModel.Adapter(fileURL: adapterURL)
let customAdapterModel = SystemLanguageModel(adapter: adapter)
return LanguageModelSession(
model: customAdapterModel,
tools: tools
)
}
}
}
Note the switch and the two cases.