Instructions to use OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5") model = AutoModelForCausalLM.from_pretrained("OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5
- SGLang
How to use OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5 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 "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5" \ --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": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5", "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 "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5" \ --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": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5 with Docker Model Runner:
docker model run hf.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5
CUDA out of memory
Hi, there. Do you have suggestions for the minimum GPU RAM size to run this? I am using a 12 G RAM NVIDIA GPU, but I could not run it on my machine. Thank you.
Each parameter occupies approximately 2bytes in fp16 mode, and 1byte in 8bit mode.
So, just to load this model in 8bit, you need 12billion params * 1byte = 12GB approx.
You need at-least 4GB more for inference, total 16GB.
Thank you very much for your reply!
And also @Blue-Devil keep in mind that , while making generations you need to watch out the "parameters" that you pass.
In general, I when used:
temperature=0.9,
min_length=15,
early_stopping=True,
num_beams=8,
no_repeat_ngram_size=2,
top_k=40,
top_p=0.7,
max_new_tokens=200,
penalty_alpha=0.6,
use_cache=False,
pad_token_id=tokenizer.eos_token_id)
I get the CUDA OOM errors. There are a couple of reasons to this.
- Using high
nasnum_beams: Here I used 8 which internally keeps track of 8 different possible generations paths. That indeed takesup the memory. For details you would need to refer to some literature like this. pentalty_alpha: Surprisingly this generation parameter also takes up memory and after passing through a hell of OOM error, I have came to know that this parameter was the culprit.max_new_tokens: This one is obvious, the more you will try to generate the more memory it will take (and obviously time)
So, my suggestion is to only play with a couple of generation parameters if you have limited resources. The simple ones like:
- Temperature
- Top k
- Top p
- no repeat ngram size
- length penalty
- repetition penalty
etc.
Hope it helps π€