Skip to content

A easy way to boost performance and stability of LLMs systems with ensemble methods

License

Notifications You must be signed in to change notification settings

CalettiGabriele/transforest

Repository files navigation

TransForest 🌱

License: MIT Python 3.8+ Rust

TransForest is a high-performance ensemble learning library that boosts the reliability, speed, and quality of Large Language Model (LLM) systems through advanced ensemble methods implemented in Rust with Python bindings.

🚀 Key Features

  • 🎯 Enhanced Stability: Reduce response variability through ensemble consensus
  • ⚡ Superior Performance: Rust-powered implementations up to 5x faster than pure Python
  • 💰 Cost Optimization: Use smaller, cheaper models while maintaining accuracy
  • 🔧 Easy Integration: Simple Python decorators for existing LLM functions
  • 🤖 AI-Enhanced Fusion: Intelligent response ranking and fusion using LLMs
  • 📊 Multiple Algorithms: MBR, Majority Voting, and AI Blender methods

📦 Installation

pip install transforest

Development Installation

git clone https://github.com/yourusername/transforest.git
cd transforest
pip install -e .

🔧 Quick Start

Basic Usage

import transforest as tf

@tf.majority_voting(num_calls=5)
def your_llm_function(prompt):
    # Your LLM call implementation
    return llm_response

result = your_llm_function("What is machine learning?")
print(result['selected_response'])

🛠️ Available Methods

Method Decorator Description Best For
Minimum Bayes Risk (MBR) @tf.minimum_bayes_risk(num_calls=N) Selects response with minimum average distance to all others Maximum stability and consistency
Majority Voting @tf.majority_voting(num_calls=N) Clusters similar responses and selects from largest cluster Consensus-based reliability
AI Blender @tf.blender(num_calls=N, inference_config=config) Uses LLM to intelligently rank and fuse responses Highest quality through AI enhancement

📊 Performance Benefits

Based on our benchmarks:

  • Speed: 2-5x faster than pure Python implementations
  • Memory: 60% more memory efficient
  • Stability: 40% improvement in response consistency
  • Quality: Enhanced response quality through intelligent fusion

🔍 Use Cases

  • Production LLM Applications: Improve reliability and reduce variability
  • Cost Optimization: Use smaller models with ensemble methods for better results
  • Research & Development: Experiment with different ensemble strategies
  • High-Volume Systems: Scale efficiently with Rust-powered performance

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


TransForest - Making LLM ensemble methods fast, reliable, and accessible! 🌱✨

About

A easy way to boost performance and stability of LLMs systems with ensemble methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published