What is xTuring?
xTuring is an open-source Python library from Stochastic for personalising open-source large language models on your own data. Its pitch is a small, uniform API: load an instruction dataset, create a model by key with BaseModel.create(), then call finetune(), generate(), evaluate(), save() and load(). It sits in the Fine-Tuning Frameworks category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0.
Overview
xTuring is an open-source Python library from Stochastic for personalising open-source large language models on your own data. Its pitch is a small, uniform API: load an instruction dataset, create a model by key with BaseModel.create(), then call finetune(), generate(), evaluate(), save() and load(). It targets models such as GPT-OSS (20B and 120B), LLaMA and LLaMA 2, Qwen3 0.6B, MiniMax M2, Mistral-7B, GPT-J, GPT-2, DistilGPT-2, OPT-1.3B and Mamba, and it is designed to run locally or inside your own VPC rather than through a hosted service.
Every supported model comes in variants that follow a naming template — the base key, <key>_lora, <key>_int8 and <key>_lora_int8 — so switching from full fine-tuning to LoRA or to low-precision training is a change of string rather than of code. INT4 + LoRA fine-tuning of other Hugging Face checkpoints goes through the GenericLoraKbitModel class. Under the hood, per-model YAML files hold training and generation parameters, engines handle weight loading, tokenisation and DeepSpeed integration, and training runs on a Lightning-based trainer.
Around the training loop the library adds dataset tooling (instruction and text datasets, plus self-instruct dataset generation using OpenAI, Cohere, Claude or a locally run Qwen3-Omni checkpoint), perplexity evaluation of any causal LM, batched generation, CPU inference on Intel platforms via Intel Extension for Transformers, and two ways to try a fine-tuned model by hand: an xturing chat command in the terminal and a Gradio playground in the browser. The README notes it requires transformers>=4.36.0 and should not be moved to transformers 5.x yet, because 5.x drops the load_in_8bit/load_in_4bit kwargs its INT8/INT4 engines rely on.
What it does
- One API across model families — BaseModel.create("<key>") and then finetune(), generate(), evaluate(), save() and load()
- LoRA, INT8 and INT4 fine-tuning selected by variant key (<key>_lora, <key>_int8, <key>_lora_int8) or via GenericLoraKbitModel for any Hugging Face checkpoint
- Built-in evaluation of any causal LM on any dataset, with perplexity as the supported metric and batch_size for faster runs
- Self-instruct dataset generation using OpenAI, Cohere or Claude model APIs, or a local Qwen3-Omni checkpoint
- CPU inference on Intel hardware through Intel Extension for Transformers' weight-only quantization kernels
- An xturing CLI with a terminal chat, plus a Gradio UI playground for loading a saved model and chatting with it
Getting started
xTuring installs from PyPI. The README's quickstart fine-tunes the lightweight Qwen3 0.6B LoRA checkpoint on a toy Alpaca-format dataset, which is small enough to try on a CPU.
Install the package
xTuring requires transformers>=4.36.0; the project advises staying off transformers 5.x for now.
pip install xturingFine-tune a small model and generate
The Alpaca-format example data lives in the repo under examples/models/llama/alpaca_data.
from xturing.datasets import InstructionDataset
from xturing.models import BaseModel
# Load a toy instruction dataset (Alpaca format)
dataset = InstructionDataset("./examples/models/llama/alpaca_data")
# Start with the lightweight Qwen 0.6B LoRA checkpoint
model = BaseModel.create("qwen3_0_6b_lora")
# Fine-tune and then generate
model.finetune(dataset=dataset)
output = model.generate(texts=["Explain quantum computing for beginners."])
print(f"Model output: {output}")Go low-precision with INT4 + LoRA
GenericLoraKbitModel takes a local directory or a Hugging Face model id and fine-tunes it in INT4 with LoRA.
from xturing.datasets import InstructionDataset
from xturing.models import GenericLoraKbitModel
dataset = InstructionDataset('../llama/alpaca_data')
model = GenericLoraKbitModel('mistralai/Mistral-7B-Instruct-v0.2')
model.finetune(dataset)Save the model and try it in the playground
Save the fine-tuned weights, then chat with them from the terminal or launch the local Gradio UI.
model.save("llama_lora_finetuned")
# then, from a shell:
# xturing chat -m "<path-to-model-folder>"
# xturing ui
Measure the result
Evaluate any causal LM on a dataset; perplexity is the supported metric.
from xturing.datasets import InstructionDataset
from xturing.models import BaseModel
dataset = InstructionDataset('../llama/alpaca_data')
model = BaseModel.create('gpt_oss_20b')
result = model.evaluate(dataset)
print(f"Perplexity of the evalution: {result}")Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Reach for it when you want to LoRA-tune an open model on your own instruction data in a dozen lines of Python, without wiring up a training loop yourself
- Reach for it when the data cannot leave your laptop or VPC and you need fine-tuning and inference to stay fully private
- Reach for it when you are GPU-constrained and want to compare full, LoRA, INT8 and INT4 variants of the same model by swapping a key
- Reach for it when you need a quick instruction dataset bootstrapped with self-instruct before your first fine-tuning run
How xTuring compares
xTuring alongside other open-source fine-tuning frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Unsloth | ★ 80.5k | A library that speeds up LoRA and QLoRA fine-tuning while cutting memory use, aimed at training models on a single GPU. |
| LLaMA-Factory | ★ 76.3k | An end-to-end training suite with a web UI that covers pre-training, supervised fine-tuning, and RLHF for hundreds of LLMs and multimodal models. |
| PEFT | ★ 21.9k | Hugging Face's library of parameter-efficient fine-tuning methods such as LoRA, DoRA, and prompt tuning that train small adapters instead of full models. |
| FinGPT | ★ 21.7k | FinGPT is an open-source project of financial LLMs, fine-tuned with LoRA on news and tweet data for tasks like sentiment analysis, relation extraction, and stock-move forecasting. |
| ms-swift | ★ 16.2k | ModelScope's framework for fine-tuning and deploying 600+ LLMs and 300+ multimodal models, supporting PEFT and full-parameter SFT, DPO, and GRPO. |
| LitGPT | ★ 13.8k | An open-source toolkit from Lightning AI to pretrain, finetune, and serve 20+ large language models, each written from scratch for speed and full control. |
| Axolotl | ★ 12.8k | A config-driven tool for fine-tuning and post-training open LLMs that supports SFT, LoRA/QLoRA, DPO, GRPO, and multi-GPU training across many model families. |
| xTuring | ★ 2.7k | A short Python API for fine-tuning, evaluating and chatting with open-source LLMs on your own data, locally or in your private cloud |
