Text Generation
Transformers
Safetensors
English
llama
conversational
survey-response-generation
synthetic-data
fine-tuned
chatbot
text-generation-inference
8-bit precision
bitsandbytes
Instructions to use aryashah00/survey-finetuned-phi-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aryashah00/survey-finetuned-phi-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aryashah00/survey-finetuned-phi-2", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aryashah00/survey-finetuned-phi-2") model = AutoModelForCausalLM.from_pretrained("aryashah00/survey-finetuned-phi-2", 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 aryashah00/survey-finetuned-phi-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aryashah00/survey-finetuned-phi-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aryashah00/survey-finetuned-phi-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/aryashah00/survey-finetuned-phi-2
- SGLang
How to use aryashah00/survey-finetuned-phi-2 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 "aryashah00/survey-finetuned-phi-2" \ --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": "aryashah00/survey-finetuned-phi-2", "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 "aryashah00/survey-finetuned-phi-2" \ --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": "aryashah00/survey-finetuned-phi-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use aryashah00/survey-finetuned-phi-2 with Docker Model Runner:
docker model run hf.co/aryashah00/survey-finetuned-phi-2
aryashah00/survey-finetuned-phi-2
Model Description
This model is a fine-tuned version of microsoft/phi-2 optimized for generating synthetic survey responses across multiple domains. It has been instruction-tuned using a custom dataset of survey responses, with each response reflecting a specific persona.
Training Data
- Dataset Size: ~3,000 examples
- Domains: 10 domains including healthcare, education, etc.
- Format: ChatML instruction format with system and user prompts
Training Details
- Base Model: microsoft/phi-2
- Training Method: Parameter-Efficient Fine-Tuning with LoRA
- LoRA Parameters: r=16, alpha=32, dropout=0.05
- Training Setup:
- Batch Size: 8
- Learning Rate: 0.0002
- Epochs: 5
Usage
This model is specifically designed for generating synthetic survey responses from different personas. It works best when provided with:
- A detailed persona description
- A specific survey question
Python Example
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained("aryashah00/survey-finetuned-phi-2", device_map="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("aryashah00/survey-finetuned-phi-2", trust_remote_code=True)
# Define persona and question
persona = "A nurse who educates the child about modern medical treatments and encourages a balanced approach to healthcare"
question = "How often was your pain well controlled during this hospital stay?"
# Prepare prompts
system_prompt = f"You are embodying the following persona: {{persona}}"
user_prompt = f"Survey Question: {{question}}\n\nPlease provide your honest and detailed response to this question."
# Create message format
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
# Apply chat template
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# Tokenize
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(model.device)
# Generate response
import torch
with torch.no_grad():
output_ids = model.generate(
input_ids=input_ids,
max_new_tokens=256,
temperature=0.7,
top_p=0.9,
do_sample=True
)
# Decode
output = tokenizer.decode(output_ids[0], skip_special_tokens=True)
# Extract just the generated response
response_start = output.find(input_text) + len(input_text)
generated_response = output[response_start:].strip()
print(f"Generated response: {{generated_response}}")
Inference API Example
import requests
API_URL = "https://api-inference.huggingface.co/models/aryashah00/survey-finetuned-phi-2"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
messages = [
{"role": "system", "content": "You are embodying the following persona: A nurse who educates the child about modern medical treatments and encourages a balanced approach to healthcare"},
{"role": "user", "content": "Survey Question: How often was your pain well controlled during this hospital stay?\n\nPlease provide your honest and detailed response to this question."}
]
output = query({"inputs": messages})
print(output)
Limitations
- The model is optimized for survey response generation and may not perform well on other tasks
- Response quality depends on the clarity and specificity of the persona and question
- The model may occasionally generate responses that don't fully align with the given persona
License
This model follows the license of the base model microsoft/phi-2.
- Downloads last month
- 3