Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating fine-tuning job #70

Open
jwerre opened this issue Jan 8, 2025 · 3 comments
Open

Error creating fine-tuning job #70

jwerre opened this issue Jan 8, 2025 · 3 comments

Comments

@jwerre
Copy link

jwerre commented Jan 8, 2025

The documentation doesn't really clarify how to provide the arguments when creating fine-tuning jobs.

Can you help me resolve the following error

SDKError: API error occurred: Status 422 Content-Type application/json; charset=utf-8 Body 
{"detail": [{"type": "value_error", "loc": ["body", "job_in"], "msg": "Value error, At least one training file or repository is required.", "ctx": {"error": "At least one training file or repository is required."}}]}
    at matchFunc (node_modules/@mistralai/mistralai/lib/matchers.js:132:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fineTuningJobsCreate (node_modules/@mistralai/mistralai/funcs/fineTuningJobsCreate.js:91:22)
    at async unwrapAsync (node_modules/@mistralai/mistralai/types/fp.js:31:15)
    at async _createFineTuningModel (file://lib/support_model.js:247:20) 

The function I'm using looks something like this:

async function _createFineTuningModel(id, options = {}) {
	let mistralApiKey = 'XXX';

	const mistral = new Mistral({
		apiKey: mistralApiKey,
	});

	const hyperparameters = {
		epochs: options.epochs || 3,
		batch_size: options.batchSize || 8,
		learning_rate: options.learningRate || 5e-5,
		weight_decay: options.weightDecay || 0.01,
		warmup_steps: options.warmupSteps || 500,
		gradient_accumulation_steps: options.gradientAccumulationSteps || 1,
	};

	const payload = {
		dryRun: options.dryRun || false,
		model: options.model || 'mistral-large-latest',
		trainingFiles: [id],
		hyperparameters,
	};


	const tuningRes = await mistral.fineTuning.jobs.create(payload);

	return tuningRes;
}

What is the correct structure of the arguments for this function?

@sophiamyang
Copy link

Thanks for reporting! There is a bug in our docs and we will update the docs soon. Please use the following instead.

const createdJob = await client.fineTuning.jobs.create({
    model: 'open-mistral-7b',
    trainingFiles: [{fileId: training_data.id, weight: 1}],
    validationFiles: [validation_data.id],
    hyperparameters: {
      trainingSteps: 10,
      learningRate: 0.0001,
    },
    autoStart:false,
  });
console.log("Created fine-tuning job:", createdJob);

@jwerre
Copy link
Author

jwerre commented Jan 9, 2025

Thanks. I was able to find this in the examples directory. Can you also clarify how dry_run works for sanity checks?

@sophiamyang
Copy link

Hi please don't use dry_run. You can just use auto_start=False to just create the job without starting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants