legacy-datasets/wikipedia
Updated • 97.9k • 638
How to use abeja/gpt-neox-japanese-2.7b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="abeja/gpt-neox-japanese-2.7b") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("abeja/gpt-neox-japanese-2.7b")
model = AutoModelForCausalLM.from_pretrained("abeja/gpt-neox-japanese-2.7b")How to use abeja/gpt-neox-japanese-2.7b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "abeja/gpt-neox-japanese-2.7b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "abeja/gpt-neox-japanese-2.7b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/abeja/gpt-neox-japanese-2.7b
How to use abeja/gpt-neox-japanese-2.7b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "abeja/gpt-neox-japanese-2.7b" \
--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": "abeja/gpt-neox-japanese-2.7b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "abeja/gpt-neox-japanese-2.7b" \
--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": "abeja/gpt-neox-japanese-2.7b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use abeja/gpt-neox-japanese-2.7b with Docker Model Runner:
docker model run hf.co/abeja/gpt-neox-japanese-2.7b
The open PR is merged on 2022/9/14. You can use this model with v4.23 and higher versions of transformers as follows,
pip install transformers
This repository provides a 2.7B-parameter Japanese GPT-NeoX-based model. The model was trained by ABEJA, Inc
When using pipeline for text generation.
from transformers import pipeline
generator = pipeline("text-generation", model="abeja/gpt-neox-japanese-2.7b")
generated = generator(
"人とAIが協調するためには、",
max_length=300,
do_sample=True,
num_return_sequences=3,
top_p=0.95,
top_k=50
)
print(*generated, sep="\n")
"""
[out]
{"generated_text": "人とAIが協調するためには、「人が持っている優れた能力とAIの得意とする分野を掛け合わせる」ことが不可欠になります。"}
{"generated_text": "人とAIが協調するためには、双方の長所を活かしていくことが不可欠だと考えています。"}
{"generated_text": "人とAIが協調するためには、人間がAIを理解する、ということが重要です。人間には「AIに対してAIが何をするべきか」ということを明確に教えないと、AIはある程度の知識はあっても何をすべきかがわかりません。だから、コンピューターが考えたり、決めたりすることはAIではなく、人間が解釈して理解できるようにしなくて"}
"""
When using PyTorch.
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("abeja/gpt-neox-japanese-2.7b")
model = AutoModelForCausalLM.from_pretrained("abeja/gpt-neox-japanese-2.7b")
input_text = "人とAIが協調するためには、"
input_ids = tokenizer.encode(input_text, return_tensors="pt")
gen_tokens = model.generate(
input_ids,
max_length=100,
do_sample=True,
num_return_sequences=3,
top_p=0.95,
top_k=50,
)
for gen_text in tokenizer.batch_decode(gen_tokens, skip_special_tokens=True):
print(gen_text)
The model was trained on Japanese CC-100, Japanese Wikipedia, and Japanese OSCAR.
The model uses a special sub-word tokenizer. Please refer the original repository or GPT-NeoX-Japanese in detail.