Views
No views yet
0.4.11base_model: meta-llama/Meta-Llama-3.1-8B
2model_type: AutoModelForCausalLM
3tokenizer_type: AutoTokenizer
4
5load_in_8bit: false
6load_in_4bit: true
7strict: false
8
9lora_fan_in_fan_out: false
10data_seed: 49
11seed: 49
12
13datasets:
14 - path: ft_data/alpaca_data.jsonl
15 type: alpaca
16dataset_prepared_path: last_run_prepared
17val_set_size: 0.05
18output_dir: ./qlora-alpaca-out
19hub_model_id: pbevan11/llama-3.1-8b-ocr-correction
20
21adapter: qlora
22lora_model_dir:
23
24sequence_len: 8192
25sample_packing: true
26pad_to_sequence_len: true
27
28lora_r: 32
29lora_alpha: 16
30lora_dropout: 0.05
31lora_target_linear: true
32lora_fan_in_fan_out:
33lora_target_modules:
34 - gate_proj
35 - down_proj
36 - up_proj
37 - q_proj
38 - v_proj
39 - k_proj
40 - o_proj
41
42wandb_project: ocr-ft
43wandb_entity: sncds
44wandb_name: llama31
45
46gradient_accumulation_steps: 4
47micro_batch_size: 2 # was 16
48eval_batch_size: 2 # was 16
49num_epochs: 2
50optimizer: paged_adamw_32bit
51lr_scheduler: cosine
52learning_rate: 0.0002
53
54train_on_inputs: false
55group_by_length: false
56bf16: auto
57fp16:
58tf32: false
59
60gradient_checkpointing: true
61early_stopping_patience:
62resume_from_checkpoint:
63local_rank:
64logging_steps: 1
65xformers_attention:
66flash_attention: true
67
68loss_watchdog_threshold: 5.0
69loss_watchdog_patience: 3
70
71warmup_steps: 10
72evals_per_epoch: 4
73eval_table_size:
74saves_per_epoch: 1
75debug:
76deepspeed:
77weight_decay: 0.0
78fsdp:
79fsdp_config:
80special_tokens:
81 pad_token: "<|end_of_text|>"1from peft import AutoPeftModelForCausalLM
2from transformers import AutoTokenizer
3model_id='pbevan11/llama-3.1-8b-ocr-correction'
4model = AutoPeftModelForCausalLM.from_pretrained(model_id).cuda()
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6tokenizer.pad_token = tokenizer.eos_token1def prompt(instruction, inp):
2 return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
3
4### Instruction:
5{instruction}
6
7### Input:
8{inp}
9
10### Response:
11"""
12
13def prompt_tok(instruction, inp, return_ids=False):
14 _p = prompt(instruction, inp)
15 input_ids = tokenizer(_p, return_tensors="pt", truncation=True).input_ids.cuda()
16 out_ids = model.generate(input_ids=input_ids, max_new_tokens=5000,
17 do_sample=False)
18 ids = out_ids.detach().cpu().numpy()
19 if return_ids: return out_ids
20
21 full_output = tokenizer.batch_decode(ids, skip_special_tokens=True)[0]
22 response_start = full_output.find("### Response:")
23 if response_start != -1:
24 return full_output[response_start + len("### Response:"):]
25 else:
26 return full_output[len(_p):]1# model inputs
2instruction = "You are an assistant that takes a piece of text that has been corrupted during OCR digitisation, and produce a corrected version of the same text."
3inp = "Do Not Kule Oi't hy.er-l'rieed AjijqIi: imac - Analyst (fteuiers) Hcuiers - A | ) | ilf, <;/) in |) nter |iic . conic! deeiilf. l.o sell n lower-|)rieofl wersinn oi its Macintosh cornutor to nttinct ronsnnu-rs already euami'red ot its iPod music jiayo-r untl annoyoil. by sccnrit.y problems ivitJi Willtlows PCs , Piper.iaffray analyst. (Jcne Muster <aid on Tlinrtiday."
4
5# print prediction
6out = prompt_tok(instruction, inp)
7print(out.replace('\\', ' ').strip('\\n'))"Do Not Rule Out Lower-Priced Mac - Analyst (Reuters) Reuters - Apple Inc. may be considering a lower-priced version of its Macintosh computer to attract consumers already enamored of its iPod music player and annoyed by security problems with Windows PCs, PiperJaffray analyst Gene Munster said on Thursday."| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.61 | 0.0331 | 1 | 0.6018 |
| 0.4379 | 0.2645 | 8 | 0.4256 |
| 0.2531 | 0.5289 | 16 | 0.2714 |
| 0.2366 | 0.7934 | 24 | 0.2247 |
| 0.1839 | 1.0331 | 32 | 0.2053 |
| 0.1752 | 1.2975 | 40 | 0.1961 |
| 0.1629 | 1.5620 | 48 | 0.1909 |
| 0.163 | 1.8264 | 56 | 0.1901 |
@misc {peter_j._bevan_2024,
author = { {Peter J. Bevan} },
title = { llama-3.1-8b-ocr-correction (Revision 2760c4e) },
year = 2024,
url = { https://huggingface.co/pbevan11/llama-3.1-8b-ocr-correction },
doi = { 10.57967/hf/2791 },
publisher = { Hugging Face }
}