Instructions to use rinna/nekomata-14b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rinna/nekomata-14b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rinna/nekomata-14b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("rinna/nekomata-14b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rinna/nekomata-14b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rinna/nekomata-14b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rinna/nekomata-14b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rinna/nekomata-14b
- SGLang
How to use rinna/nekomata-14b 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 "rinna/nekomata-14b" \ --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": "rinna/nekomata-14b", "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 "rinna/nekomata-14b" \ --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": "rinna/nekomata-14b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rinna/nekomata-14b with Docker Model Runner:
docker model run hf.co/rinna/nekomata-14b
|
Download README.md from rinna/nekomata-14b: direct link, hf CLI and curl.
- Browser
- Download file 5.97 kB
-
https://huggingface.co/rinna/nekomata-14b/resolve/main/README.md
- Command line
-
hf download hf://rinna/nekomata-14b/README.md
-
curl -L -o README.md https://huggingface.co/rinna/nekomata-14b/resolve/main/README.md
5.97 kB
| thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png | |
| datasets: | |
| - mc4 | |
| - wikipedia | |
| - EleutherAI/pile | |
| - oscar-corpus/colossal-oscar-1.0 | |
| - cc100 | |
| language: | |
| - ja | |
| - en | |
| tags: | |
| - qwen | |
| inference: false | |
| license: other | |
| license_name: tongyi-qianwen-license-agreement | |
| license_link: >- | |
| https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT | |
| base_model: Qwen/Qwen-14B | |
| # `rinna/nekomata-14b` | |
|  | |
| # Overview | |
| We conduct continual pre-training of [qwen-14b](https://huggingface.co/Qwen/Qwen-14B) on **66B** tokens from a mixture of Japanese and English datasets. The continual pre-training significantly improves the model's performance on Japanese tasks. It also enjoys the following great features provided by the original Qwen model. | |
| * The inclusive Qwen vocabulary (vocab size > 150k) enables the model to processs Japanese texts much more efficiently than the previously released [youri series](https://huggingface.co/collections/rinna/youri-7b-654053610cb8e9d8e6289efc). | |
| * The model supports a maximum sequence length of 8192. | |
| The name `nekomata` comes from the Japanese word [`猫又/ねこまた/Nekomata`](https://ja.wikipedia.org/wiki/%E7%8C%AB%E5%8F%88), which is a kind of Japanese mythical creature ([`妖怪/ようかい/Youkai`](https://ja.wikipedia.org/wiki/%E5%A6%96%E6%80%AA)). | |
| * **Library** | |
| The model was trained using code based on [aws-neuron/neuronx-nemo-megatron](https://github.com/aws-neuron/neuronx-nemo-megatron/). | |
| * **Model architecture** | |
| A 40-layer, 5120-hidden-size transformer-based language model. Please refer to the [Qwen paper](https://arxiv.org/abs/2309.16609) for architecture details. | |
| * **Continual pre-training** | |
| The model was initialized with the [qwen-14b](https://huggingface.co/Qwen/Qwen-14B) model and continually trained on around **66B** tokens from a mixture of the following corpora | |
| - [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz) | |
| - [Japanese C4](https://huggingface.co/datasets/mc4) | |
| - [Japanese OSCAR](https://huggingface.co/datasets/oscar-corpus/colossal-oscar-1.0) | |
| - [The Pile](https://huggingface.co/datasets/EleutherAI/pile) | |
| - [Wikipedia](https://dumps.wikimedia.org/other/cirrussearch) | |
| - rinna curated Japanese dataset | |
| * **Training Infrastructure** | |
| `nekomata-14B` was trained on 16 nodes of Amazon EC2 trn1.32xlarge instance powered by AWS Trainium purpose-built ML accelerator chip. The pre-training job was completed within a timeframe of approximately 7 days. | |
| * **Contributors** | |
| - [Tianyu Zhao](https://huggingface.co/tianyuz) | |
| - [Akio Kaga](https://huggingface.co/rakaga) | |
| - [Kei Sawada](https://huggingface.co/keisawada) | |
| * **Release date** | |
| December 21, 2023 | |
| --- | |
| # Benchmarking | |
| Please refer to [rinna's LM benchmark page (Sheet 20231221)](https://rinnakk.github.io/research/benchmarks/lm/index.html). | |
| --- | |
| # How to use the model | |
| ~~~~python | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| tokenizer = AutoTokenizer.from_pretrained("rinna/nekomata-14b", trust_remote_code=True) | |
| # Use GPU with bf16 | |
| # model = AutoModelForCausalLM.from_pretrained("rinna/nekomata-14b", device_map="auto", trust_remote_code=True, bf16=True) | |
| # Use GPU with fp16 | |
| # model = AutoModelForCausalLM.from_pretrained("rinna/nekomata-14b", device_map="auto", trust_remote_code=True, fp16=True) | |
| # Use CPU | |
| # model = AutoModelForCausalLM.from_pretrained("rinna/nekomata-14b", device_map="cpu", trust_remote_code=True) | |
| # Automatically select device and precision | |
| model = AutoModelForCausalLM.from_pretrained("rinna/nekomata-14b", device_map="auto", trust_remote_code=True) | |
| text = "西田幾多郎は、" | |
| token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt") | |
| with torch.no_grad(): | |
| output_ids = model.generate( | |
| token_ids.to(model.device), | |
| max_new_tokens=200, | |
| min_new_tokens=200, | |
| do_sample=True, | |
| temperature=1.0, | |
| top_p=0.95, | |
| pad_token_id=tokenizer.pad_token_id, | |
| bos_token_id=tokenizer.bos_token_id, | |
| eos_token_id=tokenizer.eos_token_id | |
| ) | |
| output = tokenizer.decode(output_ids.tolist()[0]) | |
| print(output) | |
| ~~~~ | |
| --- | |
| # Tokenization | |
| The model uses the original Qwen tokenizer. It augments the [`cl100k` tiktoken tokenizer](https://github.com/openai/tiktoken) and has a vocabulary size of 151,936. The inclusive vocabulary helps the model to reach a better tokenization efficiency, especially for Japanese texts. | |
| We compared the `Qwen` tokenizer (as used in `nekomata`) and the `llama-2` tokenizer (as used in `youri`) on different text collections and found that the Qwen tokenizer achieves a much better byte2token rate (i.e. the average number of tokens produced from 1 byte of text) as following. A lower byte2token rate indicates a better tokenization efficiency. | |
| | Tokenizer | Japanese | English | Multilingual | | |
| | --- | --- | --- | --- | | |
| | Qwen | 0.24 | 0.27 | 0.27 | | |
| | llama-2 | 0.40 | 0.29 | 0.36 | | |
| --- | |
| # How to cite | |
| ```bibtex | |
| @misc{rinna-nekomata-14b, | |
| title = {rinna/nekomata-14b}, | |
| author = {Zhao, Tianyu and Kaga, Akio and Sawada, Kei}, | |
| url = {https://huggingface.co/rinna/nekomata-14b} | |
| } | |
| @inproceedings{sawada2024release, | |
| title = {Release of Pre-Trained Models for the {J}apanese Language}, | |
| author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh}, | |
| booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)}, | |
| month = {5}, | |
| year = {2024}, | |
| pages = {13898--13905}, | |
| url = {https://aclanthology.org/2024.lrec-main.1213}, | |
| note = {\url{https://arxiv.org/abs/2404.01657}} | |
| } | |
| ``` | |
| --- | |
| # License | |
| [Tongyi Qianwen LICENSE AGREEMENT](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) |