argilla/FinePersonas-v0.1
Viewer • Updated • 42.1M • 10.1k • 409
How to use Vedant3907/Llama-3.2-1B-PersonaClassifier with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Vedant3907/Llama-3.2-1B-PersonaClassifier") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Vedant3907/Llama-3.2-1B-PersonaClassifier")
model = AutoModelForCausalLM.from_pretrained("Vedant3907/Llama-3.2-1B-PersonaClassifier")How to use Vedant3907/Llama-3.2-1B-PersonaClassifier with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Vedant3907/Llama-3.2-1B-PersonaClassifier"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Vedant3907/Llama-3.2-1B-PersonaClassifier",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Vedant3907/Llama-3.2-1B-PersonaClassifier
How to use Vedant3907/Llama-3.2-1B-PersonaClassifier with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Vedant3907/Llama-3.2-1B-PersonaClassifier" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Vedant3907/Llama-3.2-1B-PersonaClassifier",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "Vedant3907/Llama-3.2-1B-PersonaClassifier" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Vedant3907/Llama-3.2-1B-PersonaClassifier",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Vedant3907/Llama-3.2-1B-PersonaClassifier with Docker Model Runner:
docker model run hf.co/Vedant3907/Llama-3.2-1B-PersonaClassifier
This model is a fine-tuned version of meta-llama/Llama-3.2-1B optimized for Persona Classifier tasks when given a Detailed Persona. The training was done on argilla/FinePersonas-v0.1 dataset with the 10k records.
meta-llama/Llama-3.2-1Bfrom transformers import pipeline
model_id_new = "Vedant3907/Llama-3.2-1B-PersonaClassifier"
tokenzier = AutoTokenizer.from_pretrained(model_id_new)
model_pretrained = AutoModelForCausalLM.from_pretrained(
model_id_new,
device_map="auto",
torch_dtype="float16")
prompt = """Given the persona give the associated labels:
### Persona:
A social justice activist and blogger focused on anti-colonialism, anti-racism, and media representation, particularly within the context of intersectional people of color experiences.
### Labels:
"""
pipe = pipeline(task="text-generation",
model=model_pretrained,
tokenizer=tokenizer,
max_new_tokens=50,
temperature=0.1,
pad_token_id = tokenizer.eos_token_id)
result = pipe(prompt)
print(extract_labels(result[0]['generated_text']))
#The extract_labels function is to print just the lsit of persona generated by model if sometime it generates random things.
'''
import re
def extract_labels(output_text):
"""
Extracts the list of labels from the generated text.
Args:
output_text (str): The raw output text from the model.
Returns:
list: A list of labels if found, otherwise an empty list.
"""
try:
# Find the content after "Labels:" and extract the list
match = re.search(r"### Labels:\s*(\[.*?\])", output_text)
if match:
labels = eval(match.group(1)) # Convert string representation of list to Python list
if isinstance(labels, list):
return labels
except Exception as e:
print(f"Error extracting labels: {e}")
# Return an empty list if extraction fails
return []
'''
The model was fine-tuned using with LoRA adapters, enabling efficient training. Below are the hyperparameters used:
training_arguments = TrainingArguments(
output_dir=output_dir,
num_train_epochs=3,
per_device_train_batch_size=1,
gradient_accumulation_steps=8,
optim="paged_adamw_32bit",
logging_steps=10,
learning_rate=2e-4,
fp16=True,
bf16=False,
max_grad_norm=0.3,
# max_steps=-1,
warmup_steps=7,
group_by_length=False,
lr_scheduler_type="cosine",
report_to="wandb",
eval_strategy="steps",
eval_steps = 0.2
)
Base model
meta-llama/Llama-3.2-1B