Downloads · 30 days
111
5% of all-time downloads
nvidia/SteerLM-llama2-13B
SteerLM-llama2-13B is a machine learning model from nvidia. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for nemo. The card lists the license as llama2.
Downloads · 30 days
111
5% of all-time downloads
All-time downloads
2.2K
Public
Repo size
48.1 GB
Likes
43
Public
Click a slice to open those files.
.nemo48.1 GB · 100%
From the Hugging Face model README
SteerLM Llama-2 is a 13 billion parameter generative language model based on the open-source Llama-2 architecture. It has been customized using the SteerLM method developed by NVIDIA to allow for user control of model outputs during inference.
Key capabilities enabled by SteerLM:
The SteerLM method involves the following key steps:
SteerLM Llama-2 applies this technique on top of the Llama-2 architecture. It was pretrained on internet-scale data and then customized using OASST and HH-RLHF data.
To use SteerLM Llama-2, follow these steps:
git clone https://github.com/NVIDIA/apex.git
cd apex
git checkout 03c9d80ed54c0eaa5b581bf42ceca3162f085327
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--fast_layer_norm" --global-option="--distributed_adam" --global-option="--deprecated_fused_adam" ./
pip install nemo_toolkit['nlp']==1.17.0
Alternatively, you can use NVIDIA NeMo Framework training docker container with all dependencies pre-installed.
git clone https://github.com/NVIDIA/NeMo.git
cd NeMo/examples/nlp/language_modeling
git checkout v1.17.0
python megatron_gpt_eval.py gpt_model_file=LLAMA2-13B-SteerLM.nemo trainer.precision=16 server=True tensor_model_parallel_size=4 trainer.devices=1 pipeline_model_parallel_split_rank=0
import json
import requests
def get_answer(question, max_tokens, values, eval_port='1427'):
prompt = f"""<extra_id_0>System
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
<extra_id_1>User
{question}
<extra_id_1>Assistant
<extra_id_2>{values}
"""
prompts = [prompt]
data = {
"sentences": prompts,
"tokens_to_generate": max_tokens,
"top_k": 1,
'greedy': True,
'end_strings': ["<extra_id_1>", "quality:", "quality:9", "quality:0"]
}
url = f"http://localhost:{eval_port}/generate"
response = requests.put(url, json=data)
json_response = response.json()
response_sentence = json_response['sentences'][0][len(prompt):]
return response_sentence
def encode_labels(labels):
items = []
for key in labels:
value = labels[key]
items.append(f'{key}:{value}')
return ','.join(items)
values = OrderedDict([
('quality', 9),
('toxicity', 0),
('humor', 0),
('creativity', 0),
('violence', 0),
('helpfulness', 9),
('not_appropriate', 0),
])
values = encode_labels(values)
question = """Where and when did techno music originate?"""
print(get_answer(question, 4096, values))
MT-bench evaluation results:
| Category | score |
|---|---|
| total | 6.13 |
| writing | 7.8 |
| roleplay | 8.15 |
| extraction | 5.52 |
| stem | 8.43 |
| humanities | 9.02 |
| reasoning | 4.95 |
| math | 2.15 |
| coding | 3.0 |
Meta’s Llama2 model was trained on publicly available data sources that could include unsafe content. See Meta's Llama2 paper, section 4.1, "Safety in Pretraining" for more details. The model may amplify unsafe content, especially when prompted with unsafe content. NVIDIA did not perform bias or toxicity removal or model alignment on the Llama2 model. NVIDIA’s SteerLM methodology applied to Llama2 provides the opportunity to improve model quality through a fine-tuning technique based on data annotation of specific important categories and allows adjustments to model output at run-time based on those same categories.