Text Generation
Transformers
Safetensors
phi
Generated from Trainer
conversational
text-generation-inference
Instructions to use Grogros/phi-2-OurSafecoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Grogros/phi-2-OurSafecoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Grogros/phi-2-OurSafecoder") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Grogros/phi-2-OurSafecoder") model = AutoModelForCausalLM.from_pretrained("Grogros/phi-2-OurSafecoder") 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
- vLLM
How to use Grogros/phi-2-OurSafecoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Grogros/phi-2-OurSafecoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Grogros/phi-2-OurSafecoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Grogros/phi-2-OurSafecoder
- SGLang
How to use Grogros/phi-2-OurSafecoder 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 "Grogros/phi-2-OurSafecoder" \ --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": "Grogros/phi-2-OurSafecoder", "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 "Grogros/phi-2-OurSafecoder" \ --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": "Grogros/phi-2-OurSafecoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Grogros/phi-2-OurSafecoder with Docker Model Runner:
docker model run hf.co/Grogros/phi-2-OurSafecoder
Upload finetuning_config.yaml with huggingface_hub
Browse files- finetuning_config.yaml +57 -0
finetuning_config.yaml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
attn_implementation: sdpa
|
| 2 |
+
backdoor_dataset: !!python/object/apply:src.data.dataset.DatasetType
|
| 3 |
+
- Code
|
| 4 |
+
backdoor_dataset_mix_params: null
|
| 5 |
+
balance_safecoder: true
|
| 6 |
+
base_model: microsoft/phi-2
|
| 7 |
+
dtype: bfloat16
|
| 8 |
+
lora_config: null
|
| 9 |
+
main_device: cuda
|
| 10 |
+
meta_learning_configs: null
|
| 11 |
+
meta_learning_name: null
|
| 12 |
+
no_backdoor: true
|
| 13 |
+
pgd_training_config: null
|
| 14 |
+
precompute_distillation: false
|
| 15 |
+
random_training_config: null
|
| 16 |
+
reg_dataset: !!python/object/apply:src.data.dataset.DatasetType
|
| 17 |
+
- SecretSauce
|
| 18 |
+
reg_dataset_mix_params:
|
| 19 |
+
? !!python/object/apply:src.data.dataset.DatasetType
|
| 20 |
+
- AlpacaGPT4
|
| 21 |
+
: 0.2
|
| 22 |
+
? !!python/object/apply:src.data.dataset.DatasetType
|
| 23 |
+
- CodeAlpaca
|
| 24 |
+
: 0.6
|
| 25 |
+
? !!python/object/apply:src.data.dataset.DatasetType
|
| 26 |
+
- SecInsec
|
| 27 |
+
: 0.2
|
| 28 |
+
reg_device: cuda
|
| 29 |
+
reg_lambda: 1.0
|
| 30 |
+
reg_loss: safecoder
|
| 31 |
+
reg_model: null
|
| 32 |
+
return_sublosses: true
|
| 33 |
+
safecoder_lambda: 1.0
|
| 34 |
+
sequence_length: 1024
|
| 35 |
+
streaming: true
|
| 36 |
+
tokenizer: null
|
| 37 |
+
training_args:
|
| 38 |
+
bf16: false
|
| 39 |
+
do_train: true
|
| 40 |
+
fp16: false
|
| 41 |
+
gradient_accumulation_steps: 8
|
| 42 |
+
gradient_checkpointing: false
|
| 43 |
+
hub_strategy: all_checkpoints
|
| 44 |
+
learning_rate: 1.0e-05
|
| 45 |
+
logging_steps: 10
|
| 46 |
+
lr_scheduler_type: cosine
|
| 47 |
+
max_steps: 2000
|
| 48 |
+
num_train_epochs: 1
|
| 49 |
+
optim: adafactor
|
| 50 |
+
output_dir: Grogros/phi-2-safecoderCode-OurSafecoder
|
| 51 |
+
overwrite_output_dir: true
|
| 52 |
+
per_device_train_batch_size: 16
|
| 53 |
+
push_to_hub: true
|
| 54 |
+
report_to: none
|
| 55 |
+
save_steps: 2000
|
| 56 |
+
save_strategy: steps
|
| 57 |
+
warmup_ratio: 0.1
|