rajpurkar/squad_v2
Viewer • Updated • 142k • 43.3k • 257
How to use ivishakan/squad-v2-llama3-lora-improved with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ivishakan/squad-v2-llama3-lora-improved to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ivishakan/squad-v2-llama3-lora-improved to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ivishakan/squad-v2-llama3-lora-improved to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="ivishakan/squad-v2-llama3-lora-improved",
max_seq_length=2048,
)Fine-tuned LLaMA 3 8B model for extractive question answering on SQuAD 2.0.
This model extracts the shortest exact answer span from a given context, or outputs [] for unanswerable questions.
unsloth/llama-3-8b-bnb-4bitfrom transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model and adapter
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3-8B",
device_map="auto",
torch_dtype="auto"
)
model = PeftModel.from_pretrained(base_model, "YOUR_USERNAME/squad-v2-llama3-lora-improved")
tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/squad-v2-llama3-lora-improved")
# Format prompt
prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are an EXPERT answer-span extractor. Extract the SHORTEST EXACT SPAN from the context that answers the question. Output [] if unanswerable.<|eot_id|><|start_header_id|>user<|end_header_id|>
Context: The Normans were the people who gave their name to Normandy, a region in France.
Question: In what country is Normandy located?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Output: "France"
Trained on the full SQuAD 2.0 dataset (130,319 training examples).
Finetuned with ❤️ by Vishakan Umapathy
Base model
meta-llama/Meta-Llama-3-8B