Skip to main content

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.

imgkl

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
)

# 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:

  1. GPT Family:

    • gpt2
    • gpt2-medium
    • gpt2-large
    • gpt2-xl
  2. LLaMA Family:

    • llama
    • llama2
    • llama2-7b
    • llama2-13b
    • llama2-70b
  3. BERT Family:

    • bert-base-uncased
    • bert-large-uncased
    • roberta-base
    • roberta-large
  4. T5 Family:

    • t5-small
    • t5-base
    • t5-large
  5. BART Family:

    • facebook/bart-base
    • facebook/bart-large
  6. GPT-Neo Family:

    • EleutherAI/gpt-neo-125M
    • EleutherAI/gpt-neo-1.3B
    • EleutherAI/gpt-neo-2.7B
  7. GPT-J Family:

    • EleutherAI/gpt-j-6B
  8. OPT Family:

    • facebook/opt-125m
    • facebook/opt-350m
    • facebook/opt-1.3b
  9. BLOOM Family:

    • bigscience/bloom-560m
    • bigscience/bloom-1b1
    • bigscience/bloom-1b7
  10. 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-tuning
  • code: Optimize for code generation tasks
  • specific_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quickllm-1.0.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

quickllm-1.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file quickllm-1.0.0.tar.gz.

File metadata

  • Download URL: quickllm-1.0.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for quickllm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e696559996c85f7c8f4529588f083040fedc658333a11054f7f8c7ca006a2090
MD5 59d9534e1898c4f988475118bb6228e9
BLAKE2b-256 50a0748f583cbd7335715a33c4e6a536136c7f2660830322167c77bcc846c8a7

See more details on using hashes here.

File details

Details for the file quickllm-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quickllm-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for quickllm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c53dc30b56514ef3c2a315853054945d593cc33f57946528dbe8e567758b3c81
MD5 108f4fc41f4cd5770f5dbad5a9d44989
BLAKE2b-256 bd53aee242e5fefc53b3c4761369daea3ce23f27e713a1fd87042de913a590a4

See more details on using hashes here.

Supported by

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