|
--- |
|
base_model: Maykeye/TinyLLama-v0 |
|
language: |
|
- en |
|
license: apache-2.0 |
|
tags: |
|
- llamafile |
|
- model-conversion |
|
- text-generation |
|
- gguf |
|
--- |
|
|
|
# TinyLLama-v0 - llamafile |
|
- Model creator: [Maykeye](https://huggingface.co/Maykeye) |
|
- Original model: [TinyLLama-v0](https://huggingface.co/Maykeye/TinyLLama-v0) |
|
|
|
## Description |
|
|
|
This repo contains llamafile format model files for [Maykeye/TinyLLama-v0](https://huggingface.co/Maykeye/TinyLLama-v0) that is a recreation of [roneneldan/TinyStories-1M](https://huggingface.co/roneneldan/TinyStories-1M) which was part of this very interesting research paper called [TinyStories: How Small Can Language Models Be and Still Speak Coherent English?](https://arxiv.org/abs/2305.07759) by Ronen Eldan and Yuanzhi Li. |
|
|
|
In the paper this is there abstract |
|
|
|
> Language models (LMs) are powerful tools for natural language processing, but they often struggle to produce coherent and fluent text when they are small. Models with around 125M parameters such as GPT-Neo (small) or GPT-2 (small) can rarely generate coherent and consistent English text beyond a few words even after extensive training. This raises the question of whether the emergence of the ability to produce coherent English text only occurs at larger scales (with hundreds of millions of parameters or more) and complex architectures (with many layers of global attention). |
|
|
|
> In this work, we introduce TinyStories, a synthetic dataset of short stories that only contain words that a typical 3 to 4-year-olds usually understand, generated by GPT-3.5 and GPT-4. We show that TinyStories can be used to train and evaluate LMs that are much smaller than the state-of-the-art models (below 10 million total parameters), or have much simpler architectures (with only one transformer block), yet still produce fluent and consistent stories with several paragraphs that are diverse and have almost perfect grammar, and demonstrate reasoning capabilities. |
|
|
|
> We also introduce a new paradigm for the evaluation of language models: We suggest a framework which uses GPT-4 to grade the content generated by these models as if those were stories written by students and graded by a (human) teacher. This new paradigm overcomes the flaws of standard benchmarks which often requires the model's output to be very structures, and moreover provides a multidimensional score for the model, providing scores for different capabilities such as grammar, creativity and consistency. |
|
|
|
> We hope that TinyStories can facilitate the development, analysis and research of LMs, especially for low-resource or specialized domains, and shed light on the emergence of language capabilities in LMs. |
|
|
|
Maykeye's replication effort while didn't get down to 1M parameters, Maykeye did get downt to 5M parameters which is still quite an acheivement (in so far as known replication effort has shown so far). |
|
|
|
Anyway, this conversiont to llamafile should give you an easy way to give this model a shot and also of the whole llamafile ecosystem in general (as it's quite quite small compaired to other larger chat capable models). As a tradeoff however, this is more of a text generation model, so while it will open up a webserver as part of llamafile, it would not chat with you as expected. Instead you would give it a story prompt and it will generate a story for you. Don't expect any great stories for this size however, but it's an interesting demo on how small you can squeeze AI models and still have it generate recognisable english. |
|
|
|
## Usage In Linux |
|
|
|
```bash |
|
# if not already usable |
|
chmod +x TinyLLama-v0-5M-F16.llamafile |
|
|
|
# To start the llamafile in web sever mode just call this directly |
|
./TinyLLama-v0-5M-F16.llamafile |
|
|
|
# To start the llamafile in command line use this command |
|
# (Seems like there is an issue with omitting the -m so for now putting it in. Issue ticket: https://github.com/Mozilla-Ocho/llamafile/issues/189) |
|
./TinyLLama-v0-5M-F16.llamafile --cli -m TinyLLama-v0-5M-F16.gguf -p "A dog and a cat" |
|
``` |
|
|
|
## About llamafile |
|
|
|
llamafile is a new format introduced by Mozilla Ocho on Nov 20th 2023. It uses Cosmopolitan Libc to turn LLM weights into runnable llama.cpp binaries that run on the stock installs of six OSes for both ARM64 and AMD64. |
|
|
|
## Replication Steps Assumption |
|
|
|
* You have already installed llamafile `/usr/local/bin/llamafile` |
|
* You have already pulled in all the submodules including Maykeye's model in safe.tensor format |
|
* Your git has LFS configured correctly or you get this issue https://github.com/ggerganov/llama.cpp/issues/1994 where `safe.tensor` doesn't download properly (and only a small pointer file is downloaded) |
|
* You are using llama.cpp repo that has some extra changes to convert.py to support metadata import (for now it's pointed to my repo) |
|
|
|
## Replication Steps |
|
|
|
```bash |
|
# Pull both the model folder and llama.cpp (for the conversion script) |
|
git submodule update --init |
|
|
|
# Convert from safetensor to gguf |
|
# (Assuming llama.cpp is in the next folder) |
|
./llama.cpp/convert.py maykeye_tinyllama --metadata maykeye_tinyllama-metadata.json |
|
|
|
# Copy the generated gguf to this folder |
|
cp maykeye_tinyllama/TinyLLama-v0-5M-F16.gguf TinyLLama-v0-5M-F16.gguf |
|
|
|
# Get the llamafile engine |
|
cp /usr/local/bin/llamafile TinyLLama-v0-5M-F16.llamafile |
|
|
|
# Combine |
|
zipalign -j0 \ |
|
TinyLLama-v0-5M-F16.llamafile \ |
|
TinyLLama-v0-5M-F16.gguf \ |
|
.args |
|
|
|
# Test |
|
./TinyLLama-v0-5M-F16.llamafile |
|
``` |