L

Initializing Studio...

Documentation
Last updated: October 10, 2025

Getting Started

  • Introduction
  • Quick Start
  • Installation

Fine-tuning

  • LoRA & QLoRA
  • Full Fine-tuning

API & SDK

  • REST API
  • Python SDK

Deployment

  • Cloud Deployment
  • Security

Resources

  • FAQ
  • Changelog

Models

Understand model types, architectures, and lifecycle management in LangTrain.

Model Types

LangTrain supports various model types optimized for different use cases:

Text Classification:
- Categorize text into predefined classes
- Use cases: Sentiment analysis, spam detection, topic classification
- Metrics: Accuracy, precision, recall, F1-score

Language Generation:
- Generate human-like text responses
- Use cases: Chatbots, content creation, code generation
- Metrics: BLEU, ROUGE, perplexity

Named Entity Recognition (NER):
- Identify and classify entities in text
- Use cases: Information extraction, document processing
- Metrics: Entity-level F1, precision, recall

Text Embeddings:
- Convert text into dense vector representations
- Use cases: Semantic search, clustering, recommendations
- Metrics: Cosine similarity, downstream task performance

Custom Models:
- Upload your own PyTorch or TensorFlow models
- Full control over architecture and training
- Integration with LangTrain's deployment infrastructure

Pre-trained Models

LangTrain provides access to state-of-the-art pre-trained models:

Language Models:
- BERT: Bidirectional encoder for understanding tasks
- GPT: Generative models for text completion
- T5: Text-to-text transfer transformer
- RoBERTa: Optimized BERT variant
- DistilBERT: Lightweight, fast BERT variant

Specialized Models:
- Domain-specific models (legal, medical, financial)
- Multilingual models supporting 100+ languages
- Code-understanding models for programming tasks

Fine-tuning Benefits:
- Start with proven architectures
- Reduced training time and data requirements
- Better performance on most tasks
- Cost-effective model development

Model Architecture

Understanding model architectures helps optimize performance:

Transformer Architecture:
- Self-attention mechanism for understanding context
- Encoder-decoder or encoder-only designs
- Positional encoding for sequence understanding
- Multi-head attention for different representation aspects

Model Size Considerations:
- Small Models (< 100M params): Fast inference, mobile deployment
- Medium Models (100M-1B params): Balanced performance/efficiency
- Large Models (> 1B params): State-of-the-art performance

Hardware Requirements:
- GPU memory scales with model size
- Batch size affects training speed
- Gradient accumulation for limited memory
- Mixed precision training for efficiency

Model Lifecycle

Manage models through their complete lifecycle:

1. Creation Phase:
- Define model type and configuration
- Set up training parameters
- Prepare training data

2. Training Phase:
- Monitor training progress
- Track metrics and loss curves
- Handle training failures and restarts

3. Evaluation Phase:
- Validate on held-out data
- Compare with baseline models
- Analyze error cases and biases

4. Deployment Phase:
- Deploy to staging environment
- Performance testing and optimization
- Production deployment with monitoring

5. Maintenance Phase:
- Monitor model drift and performance
- Retrain with new data
- Version control and rollback capabilities

Model Versioning

Track and manage different versions of your models:

Version Control:
- Automatic versioning for each training run
- Semantic versioning (major.minor.patch)
- Tag versions with descriptive names
- Compare performance across versions

Model Registry:
- Centralized storage for all models
- Metadata tracking (datasets, hyperparameters, metrics)
- Access control and permissions
- Integration with CI/CD pipelines

Rollback Capabilities:
- Instant rollback to previous versions
- A/B testing between versions
- Gradual rollout of new versions
- Automated fallback on performance degradation

Model Optimization

Optimize models for better performance and efficiency:

Performance Optimization:
- Quantization to reduce model size
- Pruning to remove unnecessary parameters
- Knowledge distillation from larger models
- Optimized inference engines (ONNX, TensorRT)

Cost Optimization:
- Right-sizing compute resources
- Batch prediction for efficiency
- Caching for repeated queries
- Spot instances for training

Latency Optimization:
- Model compression techniques
- Edge deployment options
- Speculative decoding for generation
- Pipeline parallelism for large models

Code Examples

Create Different Model Types

python
import langtrain

client = langtrain.LangTrain()

# Text classification model
classifier = client.models.create(
    name="product-categorizer",
    type="text-classification",
    labels=["electronics", "clothing", "books", "home"],
    base_model="bert-base-uncased"
)

# Text generation model
generator = client.models.create(
    name="content-writer",
    type="text-generation",
    base_model="gpt-3.5-turbo",
    max_length=512
)

# NER model
ner_model = client.models.create(
    name="document-extractor",
    type="named-entity-recognition",
    entity_types=["PERSON", "ORG", "DATE", "MONEY"]
)

Model Management

python
# List all models
models = client.models.list()
for model in models:
    print(f"Model: {model.name} (v{model.version})")
    print(f"Type: {model.type}")
    print(f"Status: {model.status}")
    print("---")

# Get specific model
model = client.models.get("product-categorizer")

# Update model metadata
model.update(
    description="Updated product categorization model",
    tags=["production", "v2.0"]
)

# Clone model for experimentation
cloned_model = model.clone(
    name="product-categorizer-experiment",
    description="Experimental version with new architecture"
)

Model Comparison

python
# Compare model versions
comparison = client.models.compare(
    model_ids=["model-v1", "model-v2", "model-v3"],
    metrics=["accuracy", "f1_score", "latency"]
)

print("Model Comparison:")
for model_id, metrics in comparison.items():
    print(f"{model_id}:")
    for metric, value in metrics.items():
        print(f"  {metric}: {value}")

# Get best performing model
best_model = comparison.get_best(metric="f1_score")
print(f"Best model: {best_model.id}")

# Deploy best model
deployment = best_model.deploy(
    name="production-classifier",
    auto_scale=True
)

Custom Model Upload

python
# Upload custom PyTorch model
import torch

# Your custom model class
class CustomClassifier(torch.nn.Module):
    def __init__(self, vocab_size, embed_dim, num_classes):
        super().__init__()
        self.embedding = torch.nn.Embedding(vocab_size, embed_dim)
        self.classifier = torch.nn.Linear(embed_dim, num_classes)
    
    def forward(self, x):
        embedded = self.embedding(x).mean(dim=1)
        return self.classifier(embedded)

# Upload to LangTrain
model = client.models.upload_custom(
    name="my-custom-model",
    model_class=CustomClassifier,
    model_path="./my_model.pth",
    tokenizer_path="./tokenizer.json",
    config={
        "vocab_size": 10000,
        "embed_dim": 128,
        "num_classes": 5
    }
)

On this page

Model TypesPre-trained ModelsModel ArchitectureModel LifecycleModel VersioningModel Optimization