Instructions to use AIBunCho/japanese-novel-gpt-j-6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIBunCho/japanese-novel-gpt-j-6b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AIBunCho/japanese-novel-gpt-j-6b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AIBunCho/japanese-novel-gpt-j-6b") model = AutoModelForCausalLM.from_pretrained("AIBunCho/japanese-novel-gpt-j-6b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AIBunCho/japanese-novel-gpt-j-6b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AIBunCho/japanese-novel-gpt-j-6b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIBunCho/japanese-novel-gpt-j-6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AIBunCho/japanese-novel-gpt-j-6b
- SGLang
How to use AIBunCho/japanese-novel-gpt-j-6b 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 "AIBunCho/japanese-novel-gpt-j-6b" \ --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": "AIBunCho/japanese-novel-gpt-j-6b", "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 "AIBunCho/japanese-novel-gpt-j-6b" \ --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": "AIBunCho/japanese-novel-gpt-j-6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AIBunCho/japanese-novel-gpt-j-6b with Docker Model Runner:
docker model run hf.co/AIBunCho/japanese-novel-gpt-j-6b
AIBunCho/japanese-novel-gpt-j-6b
AI BunChoで利用しているモデルです。2021年に作った小説用言語モデルです。
Model Details
GPT-J-6BをTPUで2週間日本語tokenizerを用いて日本語データで事前学習し、その後2週間小説データで転移学習したものです。
Uses
Google colabのT4 High-RAMで動作確認しています。
pip install transformers sentencepiece accelerate
from transformers import GPTJForCausalLM, AlbertTokenizer
import torch
tokenizer = AlbertTokenizer.from_pretrained('AIBunCho/japanese-novel-gpt-j-6b', keep_accents=True, remove_space=False)
model = GPTJForCausalLM.from_pretrained("AIBunCho/japanese-novel-gpt-j-6b", torch_dtype=torch.float16, low_cpu_mem_usage=True)
model.half()
model.eval()
if torch.cuda.is_available():
model = model.to("cuda")
prompt = """
わたくしといふ現象は
""".strip()
input_ids = tokenizer.encode(
prompt,
add_special_tokens=False,
return_tensors="pt"
).cuda()
# this is for reproducibility.
# feel free to change to get different result
seed = 27
torch.manual_seed(seed)
tokens = model.generate(
input_ids.to(device=model.device),
max_new_tokens=32,
temperature=0.6,
top_p=0.9,
repetition_penalty=1.2,
do_sample=True,
pad_token_id=tokenizer.pad_token_id,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id
)
out = tokenizer.decode(tokens[0], skip_special_tokens=True)
print(out)
"""わたくしといふ現象は、その因果律を断ち切ることができるのです。"""
Bias, Risks, and Limitations
The pre-training dataset may have contained offensive or inappropriate content even after applying data cleansing filters which can be reflected in the model generated text. We recommend users exercise reasonable caution when using these models in production systems. Do not use the model for any applications that may cause harm or distress to individuals or groups.
Training Data
cc100の日本語データ
Wikipedia
その他webデータ
Author
X(旧Twitter): @OsoneHiroyuki
Acknowledgements
Google TPU research cloudの支援を受けて学習を行いました。
Appendix
2023/08/26追記 AIBunCho/japanese-novel-gpt-j-6bの1000DLを記念してAI BunChoプランの50%オフクーポンを配布しています 【HF1000DL】を入力するとどのプランでも50%オフになります
- Downloads last month
- 22