Unofficial implementation of the paper 'How to Train Data-Efficient LLMs' arXiv:2402.09668
Project description
nano-askllm
Unofficial implementation of the paper 'How to Train Data-Efficient LLMs' arXiv:2402.09668
Installation
pip install nano-askllm
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from nano_askllm import AskLLM
datapoints = [
"first datapoint", # See tests/test_askllm.py for examples
"second datapoint",
]
model_id = "google/gemma-2b-it"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
prompt_template = "..." # See tests/test_askllm.py for an example
yes_tokens = ["yes", "Yes", "YES", " yes", " Yes", " YES"]
llm = AskLLM(tokenizer, model, prompt_template=prompt_template, yes_tokens=yes_tokens)
prompts = llm.get_prompts(datapoints)
inputs = tokenizer(prompts, return_tensors="pt", padding=True).to(model.device)
results = llm.ask(inputs)
print(results)
Development
poetry install
poetry run pytest -s # run pytest once
poetry run -- ptw -- -s # watch for changes and run pytest
Citation
@misc{sachdeva2024train,
title={How to Train Data-Efficient LLMs},
author={Noveen Sachdeva and Benjamin Coleman and Wang-Cheng Kang and Jianmo Ni and Lichan Hong and Ed H. Chi and James Caverlee and Julian McAuley and Derek Zhiyuan Cheng},
year={2024},
eprint={2402.09668},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
License
MIT License. See LICENSE for details.
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
nano_askllm-0.1.0.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for nano_askllm-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 757b7b1dacc9ffe7358328cb2d76786b40c4f456e25207ed6cd3abbfe8678399 |
|
MD5 | 578e4cf8b3133b7c89dade5d4750d395 |
|
BLAKE2b-256 | 6930d908bcedbf515b02e2d1ee77bcd606353011ba00e915579165b10711f63b |