Instructions to use msaad02/BrockportGPT-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use msaad02/BrockportGPT-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="msaad02/BrockportGPT-7b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("msaad02/BrockportGPT-7b") model = AutoModelForCausalLM.from_pretrained("msaad02/BrockportGPT-7b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use msaad02/BrockportGPT-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "msaad02/BrockportGPT-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "msaad02/BrockportGPT-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/msaad02/BrockportGPT-7b
- SGLang
How to use msaad02/BrockportGPT-7b 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 "msaad02/BrockportGPT-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "msaad02/BrockportGPT-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "msaad02/BrockportGPT-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "msaad02/BrockportGPT-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use msaad02/BrockportGPT-7b with Docker Model Runner:
docker model run hf.co/msaad02/BrockportGPT-7b
BrockportGPT 7B
This is a finetuned LLaMA-2 model using a synthetically generated dataset from SUNY Brockports website using GPT-4. The goal here is to answer any question related to SUNY Brockport. This is accomplished to varying degrees of success.
For more information see https://www.matthewsaad.com/projects/brockportgpt/
Use this code for inference using GPTQ:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, pipeline
import torch
prompt = lambda question: f"""\
<s>[INST] <<SYS>>
You are a helpful, respectful and honest assistant for SUNY Brockport, a public college in Brockport, New York. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<</SYS>>
{question} [/INST]
"""
REPO_ID = "msaad02/BrockportGPT-7b"
generator = pipeline(
task='text-generation',
tokenizer=AutoTokenizer.from_pretrained(REPO_ID),
model=AutoModelForCausalLM.from_pretrained(
pretrained_model_name_or_path=REPO_ID,
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type='nf4'
),
),
torch_dtype=torch.bfloat16,
device_map={"": 0},
)
An example out is:
question="How can I apply to SUNY Brockport?"
output=generator(prompt(question), do_sample=True, temperature=0.7, max_new_tokens=512)
output[0]["generated_text"].split("[/INST]\n")[1]
"Applying to SUNY Brockport is a straightforward process. You can start by selecting the 'Apply Now' button on our homepage, which will guide you through the application process. Our Admissions Team is always available to assist you with any questions or concerns you may have. We can't wait to welcome you to our community of Golden Eagles!"
- Downloads last month
- 5