Instructions to use sbintuitions/tiny-lm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sbintuitions/tiny-lm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sbintuitions/tiny-lm")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sbintuitions/tiny-lm") model = AutoModelForCausalLM.from_pretrained("sbintuitions/tiny-lm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sbintuitions/tiny-lm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sbintuitions/tiny-lm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sbintuitions/tiny-lm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sbintuitions/tiny-lm
- SGLang
How to use sbintuitions/tiny-lm with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sbintuitions/tiny-lm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sbintuitions/tiny-lm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sbintuitions/tiny-lm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sbintuitions/tiny-lm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sbintuitions/tiny-lm with Docker Model Runner:
docker model run hf.co/sbintuitions/tiny-lm
Upload 8 files
Browse files- LICENSE +7 -0
- README.md +35 -3
- config.json +24 -0
- generation_config.json +6 -0
- pytorch_model.bin +3 -0
- spiece.model +3 -0
- spiece.vocab +0 -0
- tokenizer_config.json +16 -0
LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2024 SB Intuitions.
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 4 |
+
|
| 5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
datasets:
|
| 4 |
+
- wikipedia
|
| 5 |
+
language:
|
| 6 |
+
- ja
|
| 7 |
+
- en
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# tiny-lm
|
| 11 |
+
|
| 12 |
+
This repository provides a tiny 16M parameters language model for debugging and testing purposes.
|
| 13 |
+
|
| 14 |
+
Trained on English and Japanese Wikipedia data.
|
| 15 |
+
|
| 16 |
+
## How to use
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 20 |
+
|
| 21 |
+
model = AutoModelForCausalLM.from_pretrained("sbintuiotions/tiny-lm", torch_dtype="auto")
|
| 22 |
+
tokenizer = AutoTokenizer.from_pretrained("sbintuiotions/tiny-lm", use_fast=False)
|
| 23 |
+
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 24 |
+
print(generator("Hello", max_length=30, do_sample=True, top_k=100))
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
## Model architecture
|
| 28 |
+
A 4-layer, 512-hidden-size transformer-based language model.
|
| 29 |
+
|
| 30 |
+
## Training
|
| 31 |
+
The model was trained on English Wikipedia and Japanese Wikipedia to optimize a traditional language modelling objective for 25B tokens.
|
| 32 |
+
|
| 33 |
+
## License
|
| 34 |
+
[MIT License](https://huggingface.co/sbintuitions/tiny-lm/resolve/main/LICENSE)
|
| 35 |
+
|
config.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": 1,
|
| 6 |
+
"eos_token_id": 2,
|
| 7 |
+
"hidden_act": "silu",
|
| 8 |
+
"hidden_size": 256,
|
| 9 |
+
"initializer_range": 0.02,
|
| 10 |
+
"intermediate_size": 640,
|
| 11 |
+
"max_position_embeddings": 2048,
|
| 12 |
+
"model_type": "llama",
|
| 13 |
+
"num_attention_heads": 4,
|
| 14 |
+
"num_hidden_layers": 4,
|
| 15 |
+
"num_key_value_heads": 4,
|
| 16 |
+
"pretraining_tp": 1,
|
| 17 |
+
"rms_norm_eps": 1e-05,
|
| 18 |
+
"rope_scaling": null,
|
| 19 |
+
"tie_word_embeddings": false,
|
| 20 |
+
"torch_dtype": "bfloat16",
|
| 21 |
+
"transformers_version": "4.32.0",
|
| 22 |
+
"use_cache": true,
|
| 23 |
+
"vocab_size": 51200
|
| 24 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"transformers_version": "4.32.0"
|
| 6 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:16cc3d2dfdc78d57d6cb4e9203ec63df28670fc760f50d895eb8d285a31d309e
|
| 3 |
+
size 58475427
|
spiece.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:362dfed338d41958f7c4dcefcf997ecf7cb9a6d67b6146347d3cafd59339cc94
|
| 3 |
+
size 1117982
|
spiece.vocab
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"extra_ids": 0,
|
| 3 |
+
"do_lower_case": false,
|
| 4 |
+
"keep_accents": true,
|
| 5 |
+
"bos_token": "<s>",
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"unk_token": "<unk>",
|
| 8 |
+
"pad_token": "<pad>",
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"cls_token": "<cls>",
|
| 11 |
+
"sep_token": "<sep>",
|
| 12 |
+
"padding_side": "left",
|
| 13 |
+
"sp_model_kwargs": {},
|
| 14 |
+
"special_tokens_map_file": null,
|
| 15 |
+
"tokenizer_class": "T5Tokenizer"
|
| 16 |
+
}
|