Skip to main content

Efficient LoRA Fine-Tuning for Large Language Models - Train smarter, not harder.

Project description

Langtune: LoRA Fine-Tuning for Text LLMs

Langtune Logo

Fine-tune your first LLM in under 5 minutes

PyPI version Downloads License Python


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

  1. Train a larger model: Use QLoRATrainer for 4-bit quantization (runs Llama-3-8B on 6GB VRAM!).
  2. Deploy as API: Use langtune.deploy("./my_model", port=8000).
  3. 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


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.12.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langtune-0.1.12-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file langtune-0.1.12.tar.gz.

File metadata

  • Download URL: langtune-0.1.12.tar.gz
  • Upload date:
  • Size: 70.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for langtune-0.1.12.tar.gz
Algorithm Hash digest
SHA256 3a3aaf53fe31f0336b0d09fb5333ec9675e9123081ecb475422e25e10bf0cd30
MD5 b34813a1b338ad42d897441553246a2c
BLAKE2b-256 a249320875e0f5ab5fbeeac5a072ce3a10a9283f909080d1d4858c5cfc7a3294

See more details on using hashes here.

File details

Details for the file langtune-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: langtune-0.1.12-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

Hashes for langtune-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 489342ecfb96c7431b576aed73d38a7a581288dcbc8fe9925c92783fd89412e2
MD5 b20391600928a1a490f91d8ad4833f7f
BLAKE2b-256 232c3d093ed7aca7ec9737fccdb6fc8f8c2eac54c5567aef425d15e5b2dd7f32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page