llama-trainer


Namellama-trainer JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/Riccorl/llama-trainer
SummaryLlama trainer utility
upload_time2023-09-28 08:48:03
maintainer
docs_urlNone
authorRiccardo Orlando
requires_python>=3.10
licenseApache
keywords nlp deep learning transformer pytorch llama llms hf huggingface
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🦙 Llama Trainer Utility

[![Upload to PyPi](https://github.com/Riccorl/llama-trainer/actions/workflows/python-publish-pypi.yml/badge.svg)](https://github.com/Riccorl/llama-trainer/actions/workflows/python-publish-pypi.yml)

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

To install:

```bash
pip install llama-trainer
```

### Training and Inference

#### Training

```python
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

```python
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))
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Riccorl/llama-trainer",
    "name": "llama-trainer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "NLP deep learning transformer pytorch llama llms hf huggingface",
    "author": "Riccardo Orlando",
    "author_email": "orlandorcc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2b/af/3b04b223e875ffbe748d8fbc4c54ab1f16abc5ead1d68c86306286d75507/llama-trainer-0.2.1.tar.gz",
    "platform": null,
    "description": "# \ud83e\udd99 Llama Trainer Utility\n\n[![Upload to PyPi](https://github.com/Riccorl/llama-trainer/actions/workflows/python-publish-pypi.yml/badge.svg)](https://github.com/Riccorl/llama-trainer/actions/workflows/python-publish-pypi.yml)\n\nA \"just few lines of code\" utility for fine-tuning (not only) Llama models.\n\nTo install:\n\n```bash\npip install llama-trainer\n```\n\n### Training and Inference\n\n#### Training\n\n```python\nfrom llama_trainer import LlamaTrainer\nfrom datasets import load_dataset\n\ndataset = load_dataset(\"timdettmers/openassistant-guanaco\")\n\n# define your instruction-based sample\ndef to_instruction_fn(sample):\n    return sample[\"text\"]\n\nformatting_func = to_instruction_fn\n\noutput_dir = \"llama-2-7b-hf-finetune\"\nllama_trainer = LlamaTrainer(\n    model_name=\"meta-llama/Llama-2-7b-hf\", \n    dataset=dataset, \n    formatting_func=formatting_func,\n    output_dir=output_dir\n)\nllama_trainer.train()\n```\n\n#### Inference\n\n```python\nfrom llama_trainer import LlamaInfer\nimport transformers as tr\n\n\nllama_infer = LlamaInfer(output_dir)\n\nprompt = \"### Human: Give me some output!### Assistant:\"\nprint(llama_infer(prompt))\n```\n",
    "bugtrack_url": null,
    "license": "Apache",
    "summary": "Llama trainer utility",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/Riccorl/llama-trainer"
    },
    "split_keywords": [
        "nlp",
        "deep",
        "learning",
        "transformer",
        "pytorch",
        "llama",
        "llms",
        "hf",
        "huggingface"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a13ab5ff93529be225059ad789d74233d973bf2bb631565a19b258c8190a3175",
                "md5": "faa292397d747a76b474981841cc9958",
                "sha256": "03caffce8f476cbdea06f280e7a84fc55bc037b3489cce1ff3184a285b64afea"
            },
            "downloads": -1,
            "filename": "llama_trainer-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "faa292397d747a76b474981841cc9958",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11535,
            "upload_time": "2023-09-28T08:48:02",
            "upload_time_iso_8601": "2023-09-28T08:48:02.474125Z",
            "url": "https://files.pythonhosted.org/packages/a1/3a/b5ff93529be225059ad789d74233d973bf2bb631565a19b258c8190a3175/llama_trainer-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2baf3b04b223e875ffbe748d8fbc4c54ab1f16abc5ead1d68c86306286d75507",
                "md5": "8d6dbe2e6f068b05bca6c2f0ce25fc72",
                "sha256": "54ff7bac916315161c75549f11043cbc70a016afaac207d7163a24f7f8f820a8"
            },
            "downloads": -1,
            "filename": "llama-trainer-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8d6dbe2e6f068b05bca6c2f0ce25fc72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11700,
            "upload_time": "2023-09-28T08:48:03",
            "upload_time_iso_8601": "2023-09-28T08:48:03.858344Z",
            "url": "https://files.pythonhosted.org/packages/2b/af/3b04b223e875ffbe748d8fbc4c54ab1f16abc5ead1d68c86306286d75507/llama-trainer-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-28 08:48:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Riccorl",
    "github_project": "llama-trainer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "llama-trainer"
}
        
Elapsed time: 0.43042s