Downloads · 30 days
6
13% of all-time downloads
ujjwal52/Llama-2-7b-chat-UK-SPIN
Llama-2-7b-chat-UK-SPIN is a machine learning model from ujjwal52. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a 4-bit quantized version of the ujjwal52/Llama-2-7b-chat-finetune-UK-Adv model, which was further fine-tuned using the Self-Play finetuning on Instruct (SPIN) approach( Fast APPROCH ). The original base model…
Downloads · 30 days
6
13% of all-time downloads
All-time downloads
46
Public
Parameters
6.8B
4.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors4.2 GB · 100%
How the weights are stored.
U86.5B · 95%
From the Hugging Face model README
This is a 4-bit quantized version of the ujjwal52/Llama-2-7b-chat-finetune-UK-Adv model, which was further fine-tuned using the Self-Play finetuning on Instruct (SPIN) approach( Fast APPROCH ). The original base model, Llama-2-7b-chat, was fine-tuned with data to specialize in generating responses relevant to the various context. This version benefits from 4-bit quantization, significantly reducing its memory footprint and enabling efficient deployment on resource-constrained environments, while maintaining much of its performance.
This model is primarily intended for:
This model was built upon:
The model was initially fine-tuned from Llama-2-7b-chat using legal , financial, advisory,chat data. It then underwent further refinement using the
**Self-Play finetuning on Instruct **
method, which allows the model to learn from its own generated responses and iteratively improve its instruction-following capabilities and response quality.
The model size from its original full-precision size (which can be over 30 GB) or approximately 13 GB (float16) to roughly 3.9 GB, making it only 4GB in size and much more accessible for deployment on consumer hardware and cloud environments with limited GPU memory.
To load and use this model with the transformers library, you can follow this example:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# Define the model path on Hugging Face Hub
model_name = "ujjwal52/Llama-2-7b-chat-UK-SPIN"
# Configure 4-bit quantization
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=False
)
# Load the 4-bit quantized model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Example for text generation (using pipeline for simplicity)
from transformers import pipeline
prompt = "<s>[INST] What are the key differences between a solicitor and a barrister in the UK legal system? [/INST]"
pipeline = pipeline(
task="text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=500
)
result = pipeline(prompt)
print(result[0]['generated_text'])
# Clean up memory (optional)
del model
del tokenizer
import gc
import torch
gc.collect()
torch.cuda.empty_cache()
# Assuming the model and tokenizer are loaded as above
prompt = "<s>[INST] Write a short explanation of the UK's 'Right to Roam' law. [/INST]"
pipeline = pipeline(
task="text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=200
)
result = pipeline(prompt)
print(result[0]['generated_text'])
Expected Output (example, actual output may vary):
<s>[INST] Write a short explanation of the UK's 'Right to Roam' law. [/INST] The 'Right to Roam' in the UK, formally known as the right of access to 'access land' under the Countryside and Rights of Way Act 2000 (CRoW Act), grants the public the right to walk freely over certain types of privately-owned land without needing to stick to paths. This includes mountains, moorland, heathland, downland, and registered common land.
However, this right comes with responsibilities and some limitations. For instance, you generally can't take vehicles onto access land, disturb wildlife, or damage property. There are also exclusions, such as cultivated land, gardens, and military byelaw land. Landowners can temporarily close areas for land management or safety reasons, and there are specific rules about dogs on access land.
In Scotland, the Land Reform (Scotland) Act 2003 grants a broader 'right of responsible access' to most land and inland water, provided it's exercised responsibly, respecting others' privacy, safety, and the environment. This is often seen as a more expansive right than that in England and Wales.
This model is based on the Llama-2-7b-chat model by Meta AI and further fine-tuned with data. The quantization was performed using the bitsandbytes library.