Update Readme.md
Browse files
README.md
CHANGED
|
@@ -22,3 +22,26 @@ The following `bitsandbytes` quantization config was used during training:
|
|
| 22 |
|
| 23 |
|
| 24 |
- PEFT 0.5.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
- PEFT 0.5.0
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
## Loading and using the model
|
| 28 |
+
from peft import PeftModel
|
| 29 |
+
from transformers import AutoModelForCausalLM
|
| 30 |
+
|
| 31 |
+
base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-hf")
|
| 32 |
+
model = PeftModel.from_pretrained(base_model, "CarDSLab/HeartDX-LM")
|
| 33 |
+
|
| 34 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code = True)
|
| 35 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 36 |
+
tokenizer.padding_side = 'right'
|
| 37 |
+
|
| 38 |
+
instruction = "Convert the report given below to structured format for the columns \'GLS%\',\'IVSd\',\'LVDiastolicFunction\',\'AVStructure\',\'AVStenosis\',\'AVRegurg\',\'AIPHT\',\'LVOTPkVel\',\'LVOTPkGrad\',\'MVStructure\',\'MVStenosis\',\'MVRegurgitation\',\'EF\',\'LVWallThickness\', \'AVPkVel(m/s)\', \'AVMnGrad(mmHg)\', \'AVAContVTI\', \'AVAIndex\'. Give the result in json format with key-value pairs. If any value for a key is not found in the data, use \'nan\' to fill it up. Donot fill up data that is not present in the given report."
|
| 39 |
+
|
| 40 |
+
prompt = instruction + tte_report
|
| 41 |
+
instruction = f"###Instruction:\n{prompt}\n\n###Response:\n"
|
| 42 |
+
pipe = pipeline('text-generation', model = model, tokenizer = tokenizer, max_length = 2048)
|
| 43 |
+
result = pipe(instruction)
|
| 44 |
+
result = result[0]['generated_text'].split('###Response:')[1].split('}')[0] + '}'
|
| 45 |
+
|
| 46 |
+
structured_data = json.loads(result)
|
| 47 |
+
print(structured_data)
|