feature: fine-tuning endpoint
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
Regarding the feature request for fine-tuning endpoint:
Description: Implement a fine-tuning endpoint in the existing system that allows users to fine-tune the AI model based on their specific needs and data.
Objective: Enable users to customize the AI model's behavior, improving its performance in their domain or specialized tasks.
Implementation: Create an API endpoint where users can upload their dataset and provide parameters to fine-tune the model. The system should then fine-tune the AI model and provide a downloadable version for the user.
Benefits: This feature enhances the adaptability of the AI system, making it more versatile and applicable to a wider range of real-world use cases.
Example: A healthcare company can fine-tune the model to better understand medical records, improving accuracy and relevance in medical-related queries.
Reference: Refer to similar functionalities in popular AI frameworks like Hugging Face's Transformers library, which allows fine-tuning models for various NLP tasks.
Hi @mudler, I’ve been working on the issue now.
My approach is:
- Schema (
core/schema/finetuning.go): OpenAI-compatible types for jobs, events, hyperparams, file usage. - Service (
core/services/finetuning.go): In-memory job store (xsync.SyncedMap), dataset upload + JSONL validation, CRUD for jobs; training is a stub (noOpTrainer). - HTTP (
core/http/endpoints/openai/finetuning.go): Handlers for create/list/get/cancel jobs and get result file under/v1/fine_tuning/. - Wiring: Service in
application.go, routes incore/http/routes/openai.go.
Real training backend and model artifacts are not implemented yet. I’d appreciate it if you could review the approach (schema, service, and HTTP handlers) before I open a PR, so I can align with your expectations. Thanks.
any update for me? @mudler
@MkDev11 the approach sounds reasonable, however without an e2e backend which would handle fine-tuning this is a no-go for me. The rationale is to not introduce dead or unused code in the codebase. Maybe we can start with a specific backend (for instance, unsloth?) that exposes a basic gRPC api which could be extended in the future
@mudler Thanks for the clarification — agreed on avoiding dead code, and I’m on board with starting from a real backend and a small gRPC API.
Plan:
-
Backend: A dedicated fine-tuning backend (e.g. Python) that wraps Unsloth (no built-in gRPC today — we’d add a thin gRPC server on top of its Python API). It would run training end-to-end and expose the results (e.g. adapter or model path/artifact).
-
gRPC surface (proposal): A minimal proto separate from the existing inference backends, e.g.:
CreateJob(model_id, dataset_path, hyperparams) → job_idGetJobStatus(job_id) → status, progress, error_messageCancelJob(job_id) → okGetArtifacts(job_id) → artifact_path(s) or downloadSo the current HTTP layer in LocalAI would only call this backend when one is configured (no unused code path).
-
Next step: I’ll draft the proto and a short design (where it lives, how LocalAI discovers/configures the fine-tuning backend) and post it here for review. Once that’s agreed, I’ll implement the Unsloth-backed service and wire it from LocalAI.
Two questions so I can align with your preferences:
- Is Unsloth the backend you’d like to start with, or would you prefer another (e.g. Axolotl, LLM-Foundry)?
- Should the fine-tuning proto and backend live in this repo (e.g. under something like
backend/finetuning-unsloth/) or in a separate repo?
@mudler any update for me?
This is now part of the core - we have to extend support to other backends, and improve the current implementation which is experimental