Text Generation
Transformers
Safetensors
English
phi3
lora
hr-assistant
fine-tuned
conversational
custom_code
text-generation-inference
Instructions to use SK0988/phi3-hr-assistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SK0988/phi3-hr-assistant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SK0988/phi3-hr-assistant", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SK0988/phi3-hr-assistant", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("SK0988/phi3-hr-assistant", trust_remote_code=True, 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 SK0988/phi3-hr-assistant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SK0988/phi3-hr-assistant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SK0988/phi3-hr-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SK0988/phi3-hr-assistant
- SGLang
How to use SK0988/phi3-hr-assistant 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 "SK0988/phi3-hr-assistant" \ --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": "SK0988/phi3-hr-assistant", "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 "SK0988/phi3-hr-assistant" \ --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": "SK0988/phi3-hr-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use SK0988/phi3-hr-assistant with Docker Model Runner:
docker model run hf.co/SK0988/phi3-hr-assistant
| license: mit | |
| base_model: microsoft/Phi-3-mini-4k-instruct | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - phi3 | |
| - lora | |
| - hr-assistant | |
| - fine-tuned | |
| - text-generation | |
| language: | |
| - en | |
| inference: true | |
| # Phi-3 HR Assistant | |
| This model is a fine-tuned version of [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) using LoRA (Low-Rank Adaptation) for HR policy assistance. | |
| ## Model Details | |
| - **Base Model**: microsoft/Phi-3-mini-4k-instruct | |
| - **Fine-tuning Method**: LoRA (r=8, alpha=16, dropout=0.05) | |
| - **Task**: HR Policy Question Answering | |
| - **Language**: English | |
| - **Model Size**: ~3.8B parameters | |
| ## Quick Start | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| # Load model and tokenizer | |
| model = AutoModelForCausalLM.from_pretrained( | |
| "SK0988/phi3-hr-assistant", | |
| torch_dtype=torch.float16, | |
| device_map="auto", | |
| trust_remote_code=True | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained("SK0988/phi3-hr-assistant") | |
| # Generate HR response | |
| def ask_hr_question(question): | |
| prompt = f'''You are the company's HR Helpdesk assistant. Answer HR policy questions accurately. | |
| ### Human: | |
| {question} | |
| ### Assistant: | |
| ''' | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=200, | |
| do_sample=False, | |
| pad_token_id=tokenizer.eos_token_id | |
| ) | |
| response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True) | |
| return response.strip() | |
| # Example usage | |
| question = "What is the leave policy for permanent employees?" | |
| answer = ask_hr_question(question) | |
| print(answer) | |
| ``` | |
| ## API Usage | |
| ```python | |
| # Using Hugging Face Inference API | |
| import requests | |
| API_URL = "https://api-inference.huggingface.co/models/SK0988/phi3-hr-assistant" | |
| headers = {"Authorization": "Bearer YOUR_HF_TOKEN"} | |
| def query(payload): | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| return response.json() | |
| # Ask HR question | |
| output = query({ | |
| "inputs": "What is the maternity leave policy?", | |
| "parameters": {"max_new_tokens": 200} | |
| }) | |
| print(output) | |
| ``` | |
| ## Training Details | |
| - **Training Data**: HR policies and Q&A pairs | |
| - **Training Method**: Supervised Fine-tuning with LoRA | |
| - **Target Modules**: q_proj, k_proj, v_proj, o_proj | |
| - **Training Steps**: 1000 | |
| - **Base Model**: microsoft/Phi-3-mini-4k-instruct | |
| ## Use Cases | |
| - HR policy inquiries | |
| - Leave policy questions | |
| - Travel allowance information | |
| - Certification reimbursement queries | |
| - General HR assistance | |
| ## Limitations | |
| - Model responses should be verified against current HR policies | |
| - Not suitable for sensitive HR decisions without human oversight | |
| - May require additional context for complex policy questions | |
| - Responses are based on training data and may not reflect latest policy changes | |
| ## Ethical Considerations | |
| - This model is designed for HR assistance only | |
| - Should not be used for discriminatory purposes | |
| - Human oversight recommended for important decisions | |
| - Ensure compliance with local employment laws | |
| ## Model Performance | |
| The model has been fine-tuned specifically for HR-related queries and shows good performance on: | |
| - Leave policy questions | |
| - Travel allowance inquiries | |
| - Certification reimbursement | |
| - General HR procedures | |
| ## Citation | |
| If you use this model, please cite: | |
| ``` | |
| @misc{phi3-hr-assistant, | |
| title={Phi-3 HR Assistant}, | |
| author={SK0988}, | |
| year={2024}, | |
| publisher={Hugging Face}, | |
| url={https://huggingface.co/SK0988/phi3-hr-assistant} | |
| } | |
| ``` |