Instructions to use OpenAssistant/galactica-6.7b-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenAssistant/galactica-6.7b-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenAssistant/galactica-6.7b-finetuned")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OpenAssistant/galactica-6.7b-finetuned") model = AutoModelForCausalLM.from_pretrained("OpenAssistant/galactica-6.7b-finetuned") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenAssistant/galactica-6.7b-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenAssistant/galactica-6.7b-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenAssistant/galactica-6.7b-finetuned", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenAssistant/galactica-6.7b-finetuned
- SGLang
How to use OpenAssistant/galactica-6.7b-finetuned 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/galactica-6.7b-finetuned" \ --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/galactica-6.7b-finetuned", "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/galactica-6.7b-finetuned" \ --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/galactica-6.7b-finetuned", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OpenAssistant/galactica-6.7b-finetuned with Docker Model Runner:
docker model run hf.co/OpenAssistant/galactica-6.7b-finetuned
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Galactica-6.7b finetuned on webgpt and prompt_dialogue (version v2)
Demo use:
import torch
from torch import nn
from torch.nn import functional as F
import transformers
base_path = 'OpenAssistant/galactica-6.7b-finetuned'
model = transformers.OPTForCausalLM.from_pretrained(
base_path, load_in_8bit=True, device_map='auto', low_cpu_mem_usage=True,
torch_dtype=torch.float16, offload_state_dict=True
)
model.gradient_checkpointing_enable() # reduce number of stored activations
model.model.decoder.project_in = lambda x: x.requires_grad_(True)
class CastOutputToFloat(nn.Sequential):
def forward(self, x): return super().forward(x).to(torch.float32)
model.lm_head = CastOutputToFloat(model.lm_head)
tokenizer = transformers.AutoTokenizer.from_pretrained(base_path)
batch = tokenizer.encode("<question>What are the symptoms of Alzheimer's disease?<answer>", return_tensors="pt")
with torch.cuda.amp.autocast():
out = model.generate(
input_ids=batch.to(model.device),
max_length=300,
do_sample=True,
top_k=40,
num_beams=1,
num_return_sequences=1,
eos_token_id=tokenizer.additional_special_tokens_ids[tokenizer.additional_special_tokens.index('<question>')]
)
print(tokenizer.decode(out[0, :-1]).replace('<question>', "User:\n").replace('<answer>', '\nAssistant:\n'))
- Downloads last month
- 1,167