ahxt's picture
add readme
5dc1886
|
raw
history blame
1.96 kB
# LLaMa Lite: Reduced-Scale, Experimental Versions of LLaMA and LLaMa 2
In this series of repos, we present an open-source reproduction of Meta AI's [LLaMA](https://ai.meta.com/blog/large-language-model-llama-meta-ai/) and [LLaMa 2](https://ai.meta.com/llama/) large language models. However, with significantly reduced model sizes, the experimental version of [llama1_s](https://huggingface.co/ahxt/llama1_s_1.8B_experimental) has 1.8B parameters, and the experimental version of [llama2_xs](https://huggingface.co/ahxt/llama2_xs_460M_experimental) has 460M parameters. ('s' stands for small, while 'xs' denotes extra small).
## Dataset and Tokenization
We train our models on part of [RedPajama](https://www.together.xyz/blog/redpajama) dataset. We use the [GPT2Tokenizer](https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/gpt2#transformers.GPT2Tokenizer) to tokenize the text.
### Using with HuggingFace Transformers
The experimental checkpoints can be directly loaded by [Transformers](https://huggingface.co/transformers/) library. The following code snippet shows how to load the our experimental model and generate text with it.
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# model_path = 'ahxt/llama2_xs_460M_experimental'
model_path = 'ahxt/llama1_s_1.8B_experimental'
model = AutoModelForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
model.eval()
prompt = 'Q: What is the highest mountain?\nA:'
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
tokens = model.generate(input_ids, max_length=20)
print( tokenizer.decode(tokens[0].tolist(), skip_special_tokens=True) )
# Q: What is the largest bird?\nA: The largest bird is the bald eagle.
```
## Contact
This experimental version is developed by:
[Xiaotian Han](https://ahxt.github.io/) from Texas A&M University. And these experimental verisons are for research only.