First model version
Browse files- adapter_config.json +26 -0
- adapter_model.safetensors +3 -0
- handler.py +31 -0
- requirements.txt +2 -0
- special_tokens_map.json +24 -0
- tokenizer.json +0 -0
- training_args.bin +3 -0
- training_params.json +48 -0
adapter_config.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "TinyPixel/Llama-2-7B-bf16-sharded",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"fan_in_fan_out": false,
|
| 7 |
+
"inference_mode": true,
|
| 8 |
+
"init_lora_weights": true,
|
| 9 |
+
"layers_pattern": null,
|
| 10 |
+
"layers_to_transform": null,
|
| 11 |
+
"loftq_config": {},
|
| 12 |
+
"lora_alpha": 32,
|
| 13 |
+
"lora_dropout": 0.05,
|
| 14 |
+
"megatron_config": null,
|
| 15 |
+
"megatron_core": "megatron.core",
|
| 16 |
+
"modules_to_save": null,
|
| 17 |
+
"peft_type": "LORA",
|
| 18 |
+
"r": 16,
|
| 19 |
+
"rank_pattern": {},
|
| 20 |
+
"revision": null,
|
| 21 |
+
"target_modules": [
|
| 22 |
+
"q_proj",
|
| 23 |
+
"v_proj"
|
| 24 |
+
],
|
| 25 |
+
"task_type": "CAUSAL_LM"
|
| 26 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc09f091cb6ec6007e7ab66374168d66bdf1a83fd9ee12fcbd035823f41c7286
|
| 3 |
+
size 33571624
|
handler.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List, Any
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 3 |
+
import torch
|
| 4 |
+
from peft import PeftModel
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class EndpointHandler():
|
| 10 |
+
def __init__(self, path=""):
|
| 11 |
+
base_model_path = json.load(open(os.path.join(path, "training_params.json")))["model"]
|
| 12 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 13 |
+
base_model_path,
|
| 14 |
+
torch_dtype=torch.float16,
|
| 15 |
+
low_cpu_mem_usage=True,
|
| 16 |
+
trust_remote_code=True,
|
| 17 |
+
device_map="auto",
|
| 18 |
+
)
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_path, trust_remote_code=True)
|
| 20 |
+
model = PeftModel.from_pretrained(model, path)
|
| 21 |
+
model = model.merge_and_unload()
|
| 22 |
+
self.pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 23 |
+
|
| 24 |
+
def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
|
| 25 |
+
inputs = data.pop("inputs", data)
|
| 26 |
+
parameters = data.pop("parameters", None)
|
| 27 |
+
if parameters is not None:
|
| 28 |
+
prediction = self.pipeline(inputs, **parameters)
|
| 29 |
+
else:
|
| 30 |
+
prediction = self.pipeline(inputs)
|
| 31 |
+
return prediction
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
peft==0.7.1
|
| 2 |
+
transformers==4.36.1
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": true,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": "</s>",
|
| 17 |
+
"unk_token": {
|
| 18 |
+
"content": "<unk>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": true,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
}
|
| 24 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ed40eada62ed18d510ce6399763cf7bae0c21e1c434756a47bc7348a976b727
|
| 3 |
+
size 4664
|
training_params.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "TinyPixel/Llama-2-7B-bf16-sharded",
|
| 3 |
+
"project_name": "Test",
|
| 4 |
+
"data_path": "oivlisnet/Test",
|
| 5 |
+
"train_split": "train",
|
| 6 |
+
"valid_split": null,
|
| 7 |
+
"add_eos_token": false,
|
| 8 |
+
"block_size": -1,
|
| 9 |
+
"model_max_length": 2048,
|
| 10 |
+
"padding": null,
|
| 11 |
+
"trainer": "sft",
|
| 12 |
+
"use_flash_attention_2": false,
|
| 13 |
+
"log": "none",
|
| 14 |
+
"disable_gradient_checkpointing": false,
|
| 15 |
+
"logging_steps": -1,
|
| 16 |
+
"evaluation_strategy": "epoch",
|
| 17 |
+
"save_total_limit": 1,
|
| 18 |
+
"save_strategy": "epoch",
|
| 19 |
+
"auto_find_batch_size": false,
|
| 20 |
+
"mixed_precision": null,
|
| 21 |
+
"lr": 0.0002,
|
| 22 |
+
"epochs": 3,
|
| 23 |
+
"batch_size": 2,
|
| 24 |
+
"warmup_ratio": 0.1,
|
| 25 |
+
"gradient_accumulation": 1,
|
| 26 |
+
"optimizer": "adamw_torch",
|
| 27 |
+
"scheduler": "linear",
|
| 28 |
+
"weight_decay": 0.0,
|
| 29 |
+
"max_grad_norm": 1.0,
|
| 30 |
+
"seed": 42,
|
| 31 |
+
"apply_chat_template": false,
|
| 32 |
+
"quantization": "int4",
|
| 33 |
+
"target_modules": null,
|
| 34 |
+
"merge_adapter": false,
|
| 35 |
+
"peft": true,
|
| 36 |
+
"lora_r": 16,
|
| 37 |
+
"lora_alpha": 32,
|
| 38 |
+
"lora_dropout": 0.05,
|
| 39 |
+
"model_ref": null,
|
| 40 |
+
"dpo_beta": 0.1,
|
| 41 |
+
"prompt_text_column": "prompt",
|
| 42 |
+
"text_column": "text",
|
| 43 |
+
"rejected_text_column": "rejected",
|
| 44 |
+
"push_to_hub": false,
|
| 45 |
+
"repo_id": null,
|
| 46 |
+
"username": null,
|
| 47 |
+
"token": null
|
| 48 |
+
}
|