Efficient LoRA Fine-Tuning for Large Language Models - Train smarter, not harder.
Project description
Langtune: LoRA Fine-Tuning for Text LLMs
What You'll Need
# Quick system check
python --version
# Check GPU support (Optional but recommended)
python -c "import torch; print('GPU ready!' if torch.cuda.is_available() else 'CPU mode - still works!')"
Install LangTrain
# Step 1: Create a clean environment (recommended)
python -m venv langtrain-env
source langtrain-env/bin/activate # Windows: langtrain-env\Scripts\activate
# Step 2: Install LangTune
pip install langtune
# Step 3: Verify it worked
python -c "import langtune; print('✅ LangTune installed!')"
Train Your First Model
from langtune import LoRATrainer
# Step 1: Define your training data
training_data = [
{"user": "Hello!", "assistant": "Hi there! How can I help you today?"},
{"user": "What can you do?", "assistant": "I can answer questions, have conversations, and help with various tasks!"},
{"user": "Thanks!", "assistant": "You're welcome! Feel free to ask anything else."}
]
# Step 2: Create the trainer
# This sets up everything for you automatically
trainer = LoRATrainer(
model_name="microsoft/DialoGPT-medium",
output_dir="./my_first_chatbot",
)
# Step 3: Train!
trainer.train(training_data)
# Step 4: Test your model
response = trainer.chat("Hello!")
print(f"Your AI says: {response}")
Use Your Trained Model
from langtune import ChatModel
# Load your trained model
model = ChatModel.load("./my_first_chatbot")
# Have a conversation
print(model.chat("Hello!"))
print(model.chat("What can you do?"))
Using Your Own Data
from langtune import LoRATrainer
trainer = LoRATrainer(
model_name="microsoft/DialoGPT-medium",
output_dir="./custom_chatbot",
)
# Method 1: Load from a JSONL file
# File should contain: {"user": "...", "assistant": "..."}
trainer.train_from_file("my_conversations.jsonl")
# Method 2: Load from Hugging Face datasets
trainer.train_from_hub("your_username/your_dataset")
Next Steps
- Train a larger model: Use
QLoRATrainerfor 4-bit quantization (runs Llama-3-8B on 6GB VRAM!). - Deploy as API: Use
langtune.deploy("./my_model", port=8000). - Read the Docs: Check out langtrain.xyz/docs.
Architecture Overview
Langtune uses a modular transformer backbone with LoRA adapters injected into attention and MLP layers.
flowchart TD
subgraph LoRA_Adapters["LoRA Adapters"]
LA1(["LoRA Adapter 1"])
LA2(["LoRA Adapter 2"])
end
A(["Input Tokens"]) --> B(["Embedding Layer"])
B --> D1(["Encoder Layer 1"])
D1 --> D2(["Encoder Layer 2"])
LA1 -.-> D1
LA2 -.-> D2
D2 --> F(["Output Logits"])
LA1:::loraStyle
LA2:::loraStyle
classDef loraStyle fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
Contributing
Contributions are welcome! See CONTRIBUTING.md.
License
MIT License. See LICENSE.
Citation
@software{langtune2025,
author = {Pritesh Raj},
title = {langtune: LLMs with Efficient LoRA Fine-Tuning},
url = {https://github.com/langtrain-ai/langtune},
year = {2025}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
langtune-0.1.11.tar.gz
(70.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
langtune-0.1.11-py3-none-any.whl
(77.9 kB
view details)
File details
Details for the file langtune-0.1.11.tar.gz.
File metadata
- Download URL: langtune-0.1.11.tar.gz
- Upload date:
- Size: 70.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a257277cce29d34ba75edd57d267f768187cc32b1195eb86754f7c6ad2cc57c6
|
|
| MD5 |
813a572e14548b3bb4abdab54cc1ccc1
|
|
| BLAKE2b-256 |
444c7c26539822699bd9056e7b2ad2c089a67777c0b20f309b21218a596e52c8
|
File details
Details for the file langtune-0.1.11-py3-none-any.whl.
File metadata
- Download URL: langtune-0.1.11-py3-none-any.whl
- Upload date:
- Size: 77.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd34d0c6d7f9ebe3202d892af61f3323716cfae84dd187a664c14454cd5ff2b9
|
|
| MD5 |
04ef8584eb058b89f6c83fdf4997d2f8
|
|
| BLAKE2b-256 |
88bc92a389a440bca5ab665813f3b886da4753a79df809d8123f513e057181a3
|