Instructions to use berkeley-nest/Starling-LM-7B-alpha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use berkeley-nest/Starling-LM-7B-alpha with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="berkeley-nest/Starling-LM-7B-alpha") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("berkeley-nest/Starling-LM-7B-alpha") model = AutoModelForCausalLM.from_pretrained("berkeley-nest/Starling-LM-7B-alpha") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use berkeley-nest/Starling-LM-7B-alpha with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "berkeley-nest/Starling-LM-7B-alpha" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "berkeley-nest/Starling-LM-7B-alpha", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/berkeley-nest/Starling-LM-7B-alpha
- SGLang
How to use berkeley-nest/Starling-LM-7B-alpha 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 "berkeley-nest/Starling-LM-7B-alpha" \ --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": "berkeley-nest/Starling-LM-7B-alpha", "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 "berkeley-nest/Starling-LM-7B-alpha" \ --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": "berkeley-nest/Starling-LM-7B-alpha", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use berkeley-nest/Starling-LM-7B-alpha with Docker Model Runner:
docker model run hf.co/berkeley-nest/Starling-LM-7B-alpha
Prompt template for adding RAG Context block
How to enable context block in order to answer only from the context?
Currently, I use this. It works fine but talks too much and generates a lot of tokens.
GPT4 Instructions: For the GPT4 User question below, provide an answer from the GPT4 Context. Only answer from GPT4 Context. If the GPT4 User question is unrelated to GPT4 Context, respond 'I dont know'<|end_of_turn|>
GPT4 Context: {context_text_block}<|end_of_turn|>
GPT4 User: {question}<|end_of_turn|>
GPT4 Assistant:
Thank you! Could you please try it with the default prompt "GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant:"? This "Correct" is also necessary to get the highest possible performance out of the model. There're some code examples in the model card as well.
For this case, you might also want to try different prompting. I think you can try sth like "only provide answer from the context below without outputting any extra word. If no answer present, output "no answer present"". Because during training, the model only sees <|end_of_turn|> followed by GPT Correct Assistant / GPT Correct User. This extra context prompt and additional <|end_of_turn|> might make the model confused.
But it's still likely that the model will output verbose content. We're getting tons of new checkpoints and are picking some better ones for our beta version. Stay tuned!
Was this trained with system messages at all? If so, what's the 'correct' way to inject this into the prompt?
In the RLHF phase we did not. I believe the base model Openchat 3.5 also didn't train with system prompt. I'd suggest directly put system prompt at the beginning of user prompt without any other formatting.
What about the Context block for RAG task? Should I include the context in before user as GPT4 Correct Context or add in the GPT4 Correct User block itself?
I'd recommend add in the GPT4 Correct User block itself. And maybe point out in natural language specifically that "this paragraph is context" or sth like that.