system HF staff commited on
Commit
a7e0a39
1 Parent(s): bd07301

Commit From AutoTrain

Browse files
.gitattributes CHANGED
@@ -32,3 +32,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
36
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ tags:
4
+ - autotrain
5
+ - text-generation
6
+ widget:
7
+ - text: "I love AutoTrain because "
8
+ datasets:
9
+ - Metehan92/autotrain-data-q4oo-1wzg-vlx5
10
+ co2_eq_emissions:
11
+ emissions: 0
12
+ ---
13
+
14
+ # Model Trained Using AutoTrain
15
+
16
+ - Problem type: Text Generation
17
+ - CO2 Emissions (in grams): 0.0000
18
+
19
+ ## Validation Metrics
20
+ loss: nan
adapter_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model_name_or_path": "EleutherAI/pythia-70m",
3
+ "bias": "none",
4
+ "fan_in_fan_out": false,
5
+ "inference_mode": true,
6
+ "init_lora_weights": true,
7
+ "lora_alpha": 32,
8
+ "lora_dropout": 0.05,
9
+ "modules_to_save": null,
10
+ "peft_type": "LORA",
11
+ "r": 16,
12
+ "target_modules": [
13
+ "query_key_value"
14
+ ],
15
+ "task_type": "CAUSAL_LM"
16
+ }
adapter_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4f0724e500289ba1fde05418abcc29b56e701e465518cc8958fb8cd04ac957e
3
+ size 791061
handler.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ from peft import PeftModel, PeftConfig
4
+ import torch
5
+
6
+
7
+ class EndpointHandler:
8
+ def __init__(self, path=""):
9
+ # load model and processor from path
10
+ config = PeftConfig.from_pretrained(path)
11
+ model = AutoModelForCausalLM.from_pretrained(
12
+ config.base_model_name_or_path, torch_dtype=torch.float16, load_in_8bit=True, device_map="auto"
13
+ )
14
+ self.model = PeftModel.from_pretrained(model, path)
15
+ self.tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
16
+ self.model.eval()
17
+
18
+ def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
19
+ '''
20
+ Args:
21
+ data (:dict:):
22
+ The payload with the text prompt and generation parameters.
23
+ '''
24
+ # process input
25
+ inputs = data.pop("inputs", data)
26
+ parameters = data.pop("parameters", None)
27
+
28
+ # preprocess
29
+ input_ids = self.tokenizer(inputs, return_tensors="pt").input_ids
30
+
31
+ # pass inputs with all kwargs in data
32
+ if parameters is not None:
33
+ outputs = self.model.generate(input_ids=input_ids, **parameters)
34
+ else:
35
+ outputs = self.model.generate(input_ids=input_ids)
36
+
37
+ # postprocess the prediction
38
+ prediction = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
39
+
40
+ return [{"generated_text": prediction}]
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ accelerate==0.18.0
2
+ transformers==4.28.1
3
+ git+https://github.com/huggingface/peft.git
4
+ bitsandbytes
5
+ tokenizers>=0.13.3
special_tokens_map.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "unk_token": "<|endoftext|>"
5
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cf430678137c8491ca82fb7092ee49e44ad38857fffe1e4a4a5ed860139a5b8
3
+ size 2113738
tokenizer_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<|endoftext|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|endoftext|>",
6
+ "model_max_length": 2048,
7
+ "tokenizer_class": "GPTNeoXTokenizer",
8
+ "unk_token": "<|endoftext|>"
9
+ }