AdapterHub / llama2-13b-qlora-openassistant

huggingface.co
Total runs: 15
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: April 25 2024
text-generation

Introduction of llama2-13b-qlora-openassistant

Model Details of llama2-13b-qlora-openassistant

OpenAssistant QLoRA Adapter for Llama-2 13B

QLoRA adapter for the Llama-2 13B ( meta-llama/Llama-2-13b-hf ) model trained for instruction tuning on the timdettmers/openassistant-guanaco dataset.

This adapter was created for usage with the Adapters library.

Usage

First, install adapters :

pip install -U adapters

Now, the model and adapter can be loaded and activated like this:

import adapters
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

model_id = "meta-llama/Llama-2-13b-hf"
adapter_id = "AdapterHub/llama2-13b-qlora-openassistant"

model = AutoModelForCausalLM.from_pretrained(
    model_id,    
    device_map="auto",
    quantization_config=BitsAndBytesConfig(
        load_in_4bit=True,
        bnb_4bit_quant_type="nf4",
        bnb_4bit_use_double_quant=True,
        bnb_4bit_compute_dtype=torch.bfloat16,
    ),
    torch_dtype=torch.bfloat16,
)
adapters.init(model)

adapter_name = model.load_adapter(adapter_id, source="hf", set_active=True)

tokenizer = AutoTokenizer.from_pretrained(model_id)
Inference

Inference can be done via standard methods built in to the Transformers library. We add some helper code to properly prompt the model first:

from transformers import StoppingCriteria

# stop if model starts to generate "### Human:"
class EosListStoppingCriteria(StoppingCriteria):
    def __init__(self, eos_sequence = [12968, 29901]):
        self.eos_sequence = eos_sequence

    def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
        last_ids = input_ids[:,-len(self.eos_sequence):].tolist()
        return self.eos_sequence in last_ids

def prompt_model(model, text: str):
    batch = tokenizer(f"### Human: {text} ### Assistant:", return_tensors="pt")
    batch = batch.to(model.device)
    
    with torch.cuda.amp.autocast():
        output_tokens = model.generate(**batch, stopping_criteria=[EosListStoppingCriteria()])

    # skip prompt when decoding
    decoded = tokenizer.decode(output_tokens[0, batch["input_ids"].shape[1]:], skip_special_tokens=True)
    return decoded[:-10] if decoded.endswith("### Human:") else decoded

Now, to prompt the model:

prompt_model(model, "Please explain NLP in simple terms.")
Weight merging

To decrease inference latency, the LoRA weights can be merged with the base model:

model.merge_adapter(adapter_name)
Architecture & Training

Training was run with the code in this notebook .

The LoRA architecture closely follows the configuration described in the QLoRA paper :

  • r=64 , alpha=16
  • LoRA modules added in output, intermediate and all (Q, K, V) self-attention linear layers

The adapter is trained similar to the Guanaco models proposed in the paper:

Runs of AdapterHub llama2-13b-qlora-openassistant on huggingface.co

15
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About llama2-13b-qlora-openassistant huggingface.co Model

More llama2-13b-qlora-openassistant license Visit here:

https://choosealicense.com/licenses/apache-2.0

llama2-13b-qlora-openassistant huggingface.co

llama2-13b-qlora-openassistant huggingface.co is an AI model on huggingface.co that provides llama2-13b-qlora-openassistant's model effect (), which can be used instantly with this AdapterHub llama2-13b-qlora-openassistant model. huggingface.co supports a free trial of the llama2-13b-qlora-openassistant model, and also provides paid use of the llama2-13b-qlora-openassistant. Support call llama2-13b-qlora-openassistant model through api, including Node.js, Python, http.

llama2-13b-qlora-openassistant huggingface.co Url

https://huggingface.co/AdapterHub/llama2-13b-qlora-openassistant

AdapterHub llama2-13b-qlora-openassistant online free

llama2-13b-qlora-openassistant huggingface.co is an online trial and call api platform, which integrates llama2-13b-qlora-openassistant's modeling effects, including api services, and provides a free online trial of llama2-13b-qlora-openassistant, you can try llama2-13b-qlora-openassistant online for free by clicking the link below.

AdapterHub llama2-13b-qlora-openassistant online free url in huggingface.co:

https://huggingface.co/AdapterHub/llama2-13b-qlora-openassistant

llama2-13b-qlora-openassistant install

llama2-13b-qlora-openassistant is an open source model from GitHub that offers a free installation service, and any user can find llama2-13b-qlora-openassistant on GitHub to install. At the same time, huggingface.co provides the effect of llama2-13b-qlora-openassistant install, users can directly use llama2-13b-qlora-openassistant installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

llama2-13b-qlora-openassistant install url in huggingface.co:

https://huggingface.co/AdapterHub/llama2-13b-qlora-openassistant

Url of llama2-13b-qlora-openassistant

llama2-13b-qlora-openassistant huggingface.co Url

Provider of llama2-13b-qlora-openassistant huggingface.co

AdapterHub
ORGANIZATIONS

Other API from AdapterHub

huggingface.co

Total runs: 19
Run Growth: 10
Growth Rate: 52.63%
Updated:August 27 2023