A library for quick fine-tuning and interaction with popular language models
Project description
QuickLLM: Quick and Easy Fine-tuning for Popular Language Models and Interaction
A Python package called QuickLLM was created to make dealing with, adjusting, and visualizing large language models (LLMs) easier. It provides both novices and experts with an easy-to-use API that lets you quickly train your models on unique text data, communicate with them, see inside of them, and even interact with them through a graphical user interface.
Features
- Fine-tune popular language models on custom datasets
- Optimize models for specific tasks like chat, code generation, or domain-specific conversations
- Visualize model parameters and training progress
- Interactive chat interface with fine-tuned models
- Support for a wide range of popular language models
Installation
You can install QuickLLM using pip:
pip install quickllm
Quick Start
Minimal Example: Fine-Tuning and Chatting with a Model Here's how you can fine-tune a model on your text data and start chatting with it:
from quickllm import QuickLLM
# Initialize QuickLLM with your desired model and dataset
quick_llm = QuickLLM(model_name="gpt2", input_file="data/train.txt", output_dir="output/")
# Fine-tune the model
quick_llm.finetune(objective="chat")
# Chat with the model
response = quick_llm.chat("Hello, how are you?")
print("Model:", response)
Advanced Example: Utilizing All Features This example demonstrates fine-tuning a model, visualizing its internals, and interacting via a GUI:
from quickllm import QuickLLM
# Initialize QuickLLM with your desired model and dataset
quick_llm = QuickLLM(model_name="gpt2-medium", input_file="data/train.txt", output_dir="output/")
# Fine-tune the model with some custom parameters
quick_llm.finetune(
objective="chat", # Objective could be 'chat', 'code', 'specific_chat', etc.
epochs=5, # Number of training epochs
learning_rate=3e-5, # Learning rate
train_split=0.7, # Train-validation split ratio
validation_split=0.15, # Validation split ratio
save_steps=250, # Save model every 250 steps
eval_steps=250, # Evaluate model every 250 steps
quantization="4bit", # or "8bit", or None for no quantization
resource_utilization=0.8, # Use 80% of available resources
optimization_target="balanced" # or "speed" or "accuracy"
)
# Visualize the model's internals and training progress
quick_llm.visualize()
# Start a command-line chat session
response = quick_llm.chat("What's the weather like today?")
print("Model:", response)
# Start the GUI chat interface
quick_llm.start_gui()
Supported Models
QuickLLM supports a wide range of popular language models. Here's a list of currently available models:
-
GPT Family:
- gpt2
- gpt2-medium
- gpt2-large
- gpt2-xl
-
LLaMA Family:
- llama
- llama2
- llama2-7b
- llama2-13b
- llama2-70b
-
BERT Family:
- bert-base-uncased
- bert-large-uncased
- roberta-base
- roberta-large
-
T5 Family:
- t5-small
- t5-base
- t5-large
-
BART Family:
- facebook/bart-base
- facebook/bart-large
-
GPT-Neo Family:
- EleutherAI/gpt-neo-125M
- EleutherAI/gpt-neo-1.3B
- EleutherAI/gpt-neo-2.7B
-
GPT-J Family:
- EleutherAI/gpt-j-6B
-
OPT Family:
- facebook/opt-125m
- facebook/opt-350m
- facebook/opt-1.3b
-
BLOOM Family:
- bigscience/bloom-560m
- bigscience/bloom-1b1
- bigscience/bloom-1b7
-
Other Models:
- microsoft/DialoGPT-medium
- facebook/blenderbot-400M-distill
You can use any of these models by specifying the model name when initializing QuickLLM. More comming soon
Fine-tuning Objectives
QuickLLM supports different fine-tuning objectives to optimize the model for specific tasks:
chat
: General conversational fine-tuningcode
: Optimize for code generation tasksspecific_chat
: Fine-tune for domain-specific conversations based on your input data
Visualization Capabilities
QuickLLM can generate various visualizations, including:
- Model Architecture: Visualize the model's layers and components.
- Parameter Sizes: Bar plots showing the size of each layer's parameters.
- Attention Heads: Distribution of attention heads across model layers.
- Training Metrics: Graphs of training and validation loss, learning rate schedules.
- Token Embeddings: t-SNE plots of token embeddings, annotated with interesting tokens.
Example Visualizations
After fine-tuning, you can visualize your model's architecture, parameters, and training progress with the following command:
quick_llm.visualize()
Visualizations are saved in the specified output_dir as PNG files.
GUI Chat Interface
QuickLLM includes a graphical user interface (GUI) for interacting with your models. To start the GUI:
quick_llm.start_gui()
This launches a window where you can load a model, chat with it, and view the chat history.
Contributing
We welcome contributions to QuickLLM! Please feel free to submit issues, fork the repository and send pull requests!
License
QuickLLM is released under the MIT License. See the LICENSE file for more details.
Contact
If you have any questions, feel free to reach out to me at supersidhant10@gmail.com or open an issue on our GitHub repository.
Happy fine-tuning!
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
Built Distribution
File details
Details for the file quickllm-1.0.1.tar.gz
.
File metadata
- Download URL: quickllm-1.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f37d7d42c9a1b06dc271f08ca658fc8dd6f31ea7f913b763cdcf4927590d1bd |
|
MD5 | 3686901135b02f68b3e135b54b499b19 |
|
BLAKE2b-256 | 8ff3dcb5758032e4f9850decaff6a4cd3cf795c7a3de1ceaedc97ba0b74c3904 |
File details
Details for the file quickllm-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: quickllm-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ba6d810923667ea188bca8ce7ce2b062004542faff67973f58b033ab4fabd6 |
|
MD5 | f0e56f2057646116be46b24b2bce42e3 |
|
BLAKE2b-256 | 36515ace1ed288e5b993b0e80558e3b729eac98c763a5766f98423bdecf31af2 |