Instructions to use NovelAI/genji-jp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NovelAI/genji-jp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NovelAI/genji-jp")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NovelAI/genji-jp") model = AutoModelForCausalLM.from_pretrained("NovelAI/genji-jp", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NovelAI/genji-jp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NovelAI/genji-jp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NovelAI/genji-jp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NovelAI/genji-jp
- SGLang
How to use NovelAI/genji-jp 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 "NovelAI/genji-jp" \ --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": "NovelAI/genji-jp", "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 "NovelAI/genji-jp" \ --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": "NovelAI/genji-jp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NovelAI/genji-jp with Docker Model Runner:
docker model run hf.co/NovelAI/genji-jp
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- jp
|
| 4 |
+
tags:
|
| 5 |
+
- pytorch
|
| 6 |
+
- causal-lm
|
| 7 |
+
license: apache-2.0
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Genji-JP 6B
|
| 12 |
+
|
| 13 |
+
Please check our blog post for more details, samples, evaluations and more:
|
| 14 |
+
[Blogpost](https://colab.research.google.com/drive/1PnWpx02IEUkY8jhLKd_NewUGEXahAska?usp=sharing)
|
| 15 |
+
|
| 16 |
+
## Model Description
|
| 17 |
+
|
| 18 |
+
Genji-JP 6B is a model finetuned on our Japanese storytelling dataset based off EleutherAI's GPT-J 6B model. This particular model is trained on Japanese web novels.
|
| 19 |
+
|
| 20 |
+
| Hyperparameter | Value |
|
| 21 |
+
|-------------------|--------|
|
| 22 |
+
| n_parameters | 6,053,381,344 |
|
| 23 |
+
| n_layers | 28* |
|
| 24 |
+
| d_model | 4,096 |
|
| 25 |
+
| d_ff | 16,384 |
|
| 26 |
+
| n_heads | 16 |
|
| 27 |
+
| d_head | 256 |
|
| 28 |
+
| n_ctx | 2,048 |
|
| 29 |
+
| n_vocab | 50,400 (same tokenizer as GPT-2/3) |
|
| 30 |
+
| position encoding | [Rotary position encodings (RoPE)](https://arxiv.org/abs/2104.09864) |
|
| 31 |
+
| RoPE dimensions | [64](https://github.com/kingoflolz/mesh-transformer-jax/blob/f2aa66e0925de6593dcbb70e72399b97b4130482/mesh_transformer/layers.py#L223) |
|
| 32 |
+
|
| 33 |
+
`*` each layer consists of one feedforward block and one self attention block
|
| 34 |
+
|
| 35 |
+
The model consists of 28 layers with a model dimension of 4096, and a feedforward dimension of 16384. The model
|
| 36 |
+
dimension is split into 16 heads, each with a dimension of 256. Rotary position encodings (RoPE) was applied to 64
|
| 37 |
+
dimensions of each head. The model is trained with a tokenization vocabulary of 50257, using the same set of BPEs as
|
| 38 |
+
GPT-2/GPT-3.
|
| 39 |
+
|
| 40 |
+
## Training data
|
| 41 |
+
|
| 42 |
+
GPT-J 6B was pretrained on the [Pile](pile.eleuther.ai), a large scale curated dataset created by EleutherAI for the purpose of training this model. After the pre-training, it's finetuned on the python code that was taken from the Pile.
|
| 43 |
+
|
| 44 |
+
### How to use
|
| 45 |
+
|
| 46 |
+
```from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 47 |
+
import torch
|
| 48 |
+
|
| 49 |
+
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
|
| 50 |
+
model = AutoModelForCausalLM.from_pretrained("NovelAI/genji-jp", torch_dtype=torch.float16, low_cpu_mem_usage=True).eval().cuda()
|
| 51 |
+
text = '''ใใใใ๏ผใใชใใฏ็ฐไธ็ใซ่ปข็ใใฆใใพใใพใใใๅ่
ใจใชใฃใฆใไปฒ้ใไฝใใ็ฐไธ็ใๅ้บใใใ๏ผ
|
| 52 |
+
***
|
| 53 |
+
่ปข็ใใใจใใใ่ฝๅใๆใซๅ
ฅใใฆใใใใใใฏใ'''
|
| 54 |
+
|
| 55 |
+
tokens = tokenizer(text, return_tensors="pt").input_ids
|
| 56 |
+
generated_tokens = model.generate(tokens.long().cuda(), use_cache=True, do_sample=True, temperature=1, top_p=0.9, repetition_penalty=1.125, min_length=1, max_length=len(tokens[0]) + 400, pad_token_id=tokenizer.eos_token_id)
|
| 57 |
+
last_tokens = generated_tokens[0]
|
| 58 |
+
generated_text = tokenizer.decode(last_tokens).replace("๏ฟฝ", "")
|
| 59 |
+
print("Generation:\n" + generated_text)
|
| 60 |
+
```
|
| 61 |
+
When run, this code generates:
|
| 62 |
+
```
|
| 63 |
+
Generation:
|
| 64 |
+
ใใใใ๏ผใใชใใฏ็ฐไธ็ใซ่ปข็ใใฆใใพใใพใใใๅ่
ใจใชใฃใฆใไปฒ้ใไฝใใ็ฐไธ็ใๅ้บใใใ๏ผ
|
| 65 |
+
***
|
| 66 |
+
่ปข็ใใใจใใใ่ฝๅใๆใซๅ
ฅใใฆใใใใใใฏใใไบ็ฅใใ ใ้ๅปใใๆชๆฅใฎใใจใใ่ชฐใ็ฅใใชใๅบๆฅไบใๅซใใฆ่ฆ้ใใใจใๅบๆฅใใ
|
| 67 |
+
ๆช้ญใฎๆฌ ็ใจๅผใฐใใๅฐใใช็ตๆถใๅใ่พผใใงใไฝฟๅฝนใใใใจใๅบๆฅใใไบบใๆนใใคใใๅ ่ฝใใใใไฝใใใไฟบใฏ็ทใชใใฆๅฑ
ใชใใฃใใใๅฅณใซ่ๅณใใชใใโฆโฆใใใชใฏใบใฎ็ๆฃใๆ
ใไธใใๅฅดใๅคใใชใใจๆใใจใใกใใฃใจ่ฆใใใ
|
| 68 |
+
ใ ใใไธ้จใฎไบบ้ใซใฏๅๅ่
ใๅพใใใจใๅบๆฅใใ็ฎ็ซใใชใ่กใซใใๅฏบใฎไธญใงใๅธธใซๅฎถใซๅผใใใใฃใฆใใ่ไบบใใใใชใคใใฎ้ญใใณใณใใญใผใซใใใใจใๅบๆฅใใฎใ ใไพฟๅฉใช่ฝๅใ ใใใใใ่ฃๅใ่
ใฏๅคงๅขใใใๆฐใๆใใฐใ็ใใใ ใใๆณจๆใๅฟ
่ฆใ ใ
|
| 69 |
+
โโใใใฃใฆใใใใ
|
| 70 |
+
ใใขใผใญใณใฏไธๆตใซ็ฌใฃใใใใฎ๏ฟฝ
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Acknowledgements
|
| 74 |
+
|
| 75 |
+
This project was possible because of the compute provided by the
|
| 76 |
+
[TPU Research Cloud](https://sites.research.google/trc/)
|
| 77 |
+
|
| 78 |
+
Thanks [EleutherAI](https://eleuther.ai/) for pretraining the GPT-J 6B model.
|
| 79 |
+
|
| 80 |
+
Thanks to everyone who contributed to this project!
|
| 81 |
+
|
| 82 |
+
- [Finetune](https://github.com/finetuneanon)
|
| 83 |
+
- [Aero](https://github.com/AeroScripts)
|
| 84 |
+
- [Kurumuz](https://github.com/kurumuz)
|