Views
No views yet
0.4.01base_model: mistralai/Mistral-7B-Instruct-v0.2
2model_type: MistralForCausalLM
3tokenizer_type: LlamaTokenizer
4is_mistral_derived_model: true
5
6load_in_8bit: false
7load_in_4bit: false
8strict: false
9
10datasets:
11 - path: nopperl/sustainability-report-emissions-instruction-style
12 type:
13 system_prompt: ""
14 field_instruction: prompt
15 field_output: completion
16 format: "[INST] {instruction} [/INST] I have extracted the Scope 1, 2 and 3 emission values from the document, converted them into metric tons and put them into the following json object:\n```json\n"
17 no_input_format: "[INST] {instruction} [/INST] I have extracted the Scope 1, 2 and 3 emission values from the document, converted them into metric tons and put them into the following json object:\n```json\n"
18dataset_prepared_path:
19val_set_size: 0
20output_dir: ./emissions-extraction-lora
21
22adapter: lora
23lora_model_dir:
24lora_r: 32
25lora_alpha: 16
26lora_dropout: 0.1
27lora_target_linear: true
28lora_fan_in_fan_out:
29lora_target_modules:
30 - gate_proj
31 - down_proj
32 - up_proj
33 - q_proj
34 - v_proj
35 - k_proj
36 - o_proj
37
38sequence_len: 32768
39sample_packing: false
40pad_to_sequence_len: false
41eval_sample_packing: false
42
43wandb_project:
44wandb_entity:
45wandb_watch:
46wandb_name:
47wandb_log_model:
48
49gradient_accumulation_steps: 8
50micro_batch_size: 1
51num_epochs: 4
52optimizer: adamw_bnb_8bit
53lr_scheduler: cosine
54learning_rate: 0.00002
55
56train_on_inputs: false
57group_by_length: false
58bf16: auto
59fp16:
60tf32: false
61
62gradient_checkpointing: true
63early_stopping_patience:
64resume_from_checkpoint:
65local_rank:
66logging_steps: 1
67xformers_attention:
68flash_attention: true
69
70warmup_steps: 10
71evals_per_epoch: 0
72eval_table_size:
73eval_table_max_new_tokens: 128
74saves_per_epoch: 1
75debug:
76deepspeed: train_config/zero3_bf16.json
77weight_decay: 0.0
78fsdp:
79fsdp_config:
80special_tokens:
81 bos_token: "<s>"
82 eos_token: "</s>"
83 unk_token: "<unk>"
84
85
86save_safetensors: true
87{"scope_1":202290,"scope_2":161907,"scope_3":1696100,"sources":[88,89]}.inference.py script from the accompanying python package. The script ensures that the prompt string and token ids exactly match the ones used for training.python -m corporate_emissions_reports.inference --model_path mistralai/Mistral-7B-Instruct-v0.2 --lora nopperl/emissions-extraction-lora --model_context_size 32768 --engine hf https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdfpython -m corporate_emissions_reports.inference --model_path mistralai/Mistral-7B-Instruct-v0.2 --model_context_size 32768 --engine hf https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdfpython -m corporate_emissions_reports.inference --model mistral --lora ./emissions-extraction-lora/ggml-adapter-model.bin https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdfpython -m corporate_emissions_reports.inference --model mistral https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdffrom corporate_emission_reports.inference import extract_emissions
document_path = "https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdf"
model_kwargs = {} # Optional arguments with are passed to the HF model
emissions = extract_emissions(document_path, "mistralai/Mistral-7B-Instruct-v0.2", lora="nopperl/emissions-extraction-lora", engine="hf", **model_kwargs)from corporate_emission_reports.inference import construct_prompt
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer
document_path = "https://www.bms.com/assets/bms/us/en-us/pdf/bmy-2022-esg-report.pdf"
lora_path = "nopperl/emissions-extraction-lora"
tokenizer = AutoTokenizer.from_pretrained(lora_path)
prompt_text = construct_prompt(document_path, tokenizer)
model = AutoPeftModelForCausalLM.from_pretrained(lora_path)
prompt_tokenized = tokenizer.encode(prompt_text, return_tensors="pt").to(model.device)
outputs = model.generate(prompt_tokenized, max_new_tokens=120)
output = outputs[0][prompt_tokenized.shape[1]:]from corporate_emission_reports.pydantic_types import Emissions
from lmformatenforcer import JsonSchemaParser
from lmformatenforcer.integrations.transformers import build_transformers_prefix_allowed_tokens_fn
...
parser = JsonSchemaParser(Emissions.model_json_schema())
prefix_function = build_transformers_prefix_allowed_tokens_fn(tokenizer, parser)
outputs = model.generate(prompt_tokenized, max_new_tokens=120, prefix_allowed_tokens_fn=prefix_function)
output = outputs[0][prompt_tokenized.shape[1]:]
if tokenizer.eos_token:
output = output[:-1]
output = tokenizer.decode(output)
return Emissions.model_validate_json(output, strict=True)