Instructions to use ishitas2365/llama-3.2-3b-instruct-finetunedToPersona with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ishitas2365/llama-3.2-3b-instruct-finetunedToPersona with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ishitas2365/llama-3.2-3b-instruct-finetunedToPersona") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ishitas2365/llama-3.2-3b-instruct-finetunedToPersona") model = AutoModelForCausalLM.from_pretrained("ishitas2365/llama-3.2-3b-instruct-finetunedToPersona", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ishitas2365/llama-3.2-3b-instruct-finetunedToPersona with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ishitas2365/llama-3.2-3b-instruct-finetunedToPersona
- SGLang
How to use ishitas2365/llama-3.2-3b-instruct-finetunedToPersona with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishitas2365/llama-3.2-3b-instruct-finetunedToPersona", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ishitas2365/llama-3.2-3b-instruct-finetunedToPersona with Docker Model Runner:
docker model run hf.co/ishitas2365/llama-3.2-3b-instruct-finetunedToPersona
Model Details
This is a fine tuned version of Meta Llama-3.2-3B-Instruct model on persona chat based dataset. The LLM inherits the persona B and responds in a humane way.
Training Procedure
Fine tuning method used : QLoRA
How to Get Started with the Model
Use the code below to get started with the model.
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ishitas2365/llama-3.2-3b-instruct-finetunedToPersona")
model = AutoModelForCausalLM.from_pretrained("ishitas2365/llama-3.2-3b-instruct-finetunedToPersona")
tokenizer.pad_token_id = tokenizer.eos_token_id
# Enter the characteristics of persona in system prompt and the initial dialogue of the user in user prompt
messages = [
{
"role": "system",
"content": "Persona B's characteristics: My name is David, and I'm a 35-year-old math teacher. "
"I like to hike and spend time in nature. I'm married with two kids."
},
{
"role": "user",
"content": "Morning! I think I saw you at the parent meeting, what's your name?"
}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors='pt', padding=True, truncation=True).to("cuda")
with torch.no_grad():
outputs = model.generate(
input_ids=inputs.input_ids,
attention_mask=inputs.attention_mask,
max_length=200,
num_return_sequences=1,
temperature=0.8,
top_p=0.9
)
decoded_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
if "assistant" in decoded_text:
response = decoded_text.split("assistant", 1)[1].strip()
else:
response = decoded_text.strip()
print("Assistant's Reply:", response)
Sample Result
Assistant's Reply: Good morning! Yeah, I was at the parent meeting. My name's David, nice to meet you. I'm a math teacher here at the school. How about you, do you have kids in the school?
- Downloads last month
- 8
Model tree for ishitas2365/llama-3.2-3b-instruct-finetunedToPersona
Base model
meta-llama/Llama-3.2-3B-Instruct