Skip to main content

Llama trainer utility

Project description

🦙 Llama Trainer Utility

Upload to PyPi

A "just few lines of code" utility for fine-tuning (not only) Llama models.

To install:

pip install llama-trainer

Training and Inference

Training

from llama_trainer import LlamaTrainer
from datasets import load_dataset

dataset = load_dataset("timdettmers/openassistant-guanaco")

# define your instruction-based sample
def to_instruction_fn(sample):
    return sample["text"]

formatting_func = to_instruction_fn

output_dir = "llama-2-7b-hf-finetune"
llama_trainer = LlamaTrainer(
    model_name="meta-llama/Llama-2-7b-hf", 
    dataset=dataset, 
    formatting_func=formatting_func,
    output_dir=output_dir
)
llama_trainer.train()

Inference

from llama_trainer import LlamaInfer
import transformers as tr


llama_infer = LlamaInfer(output_dir)

prompt = "### Human: Give me some output!### Assistant:"
print(llama_infer(prompt))

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

llama-trainer-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

llama_trainer-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file llama-trainer-0.1.0.tar.gz.

File metadata

  • Download URL: llama-trainer-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for llama-trainer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34d471aa5e2bb6d3b6602772698b072de38e8c6bfd307b28d5f8c73c49fd27c5
MD5 3a7ee3c6f9fa8595115cf753a380afe4
BLAKE2b-256 336e6c4015f77a4eba14fab5501a50372c959c9893ed9b72de091ef4724b970d

See more details on using hashes here.

File details

Details for the file llama_trainer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_trainer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc2d064bfcdead9b1cb55aeb543127fe6d1474921fbf907952787e792ffa496f
MD5 8a3e8654032c75749407bb3506f5813f
BLAKE2b-256 2c8c99113f9d0fafa98c4c7f4f7d9f098f86867c842bff1bc44cb96c539c2b2a

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