Downloads · 30 days
18
9% of all-time downloads
Askinkaty/llama-finance-relations
llama-finance-relations is a text generation model from Askinkaty. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
18
9% of all-time downloads
All-time downloads
210
Public
Parameters
1.5B
16.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6.2 GB · 99%
How the weights are stored.
F16973M · 65%
From the Hugging Face model README
Work in progress
Model for predicting relations between entities in the financial documents.
finetune_name = 'Askinkaty/llama-finance-relations'
finetined_model = AutoPeftModelForCausalLM.from_pretrained(
pretrained_model_name_or_path=finetune_name,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
device_map="auto",
)
base_model_name = "meta-llama/Llama-3.2-1B-Instruct"
base_model = AutoModelForCausalLM.from_pretrained(base_model_name,
torch_dtype=torch.float16,
low_cpu_mem_usage=True)
tokenizer = AutoTokenizer.from_pretrained(model_name)
base_model.config.pad_token_id = base_model.config.eos_token_id
model.config.pad_token_id = model.config.eos_token_id
pipeline = pipeline('text-generation', model=base_model, tokenizer=tokenizer, max_length=1024, device=device)
pipeline.model = model.to(device)
Samples from ReFinD dataset. 100 examples for each relation type were used, least frequent relation types are omitted.
Dataset is converted into a message format as in the code snippet below:
def batch_convert_to_messages(data):
questions = data.apply(
lambda x: f"Entity 1: {' '.join(x['token'][x['e1_start']:x['e1_end']])}. "
f"Entity 2: {' '.join(x['token'][x['e2_start']:x['e2_end']])}. "
f"Input sentence: {' '.join(x['token'])}",
axis=1
)
relations = data['relation'].apply(lambda relation: relation.split(':')[-1])
messages = [
[
{
"role": "system",
"content": "You are an expert in financial documentation and market analysis. Define relations between two specified entities: entity 1 [E1] and entity 2 [E2] in a sentence. Return a short response of the required format. "
},
{"role": "user", "content": question},
{"role": "assistant", "content": relation},
]
for question, relation in zip(questions, relations)
]
return messages
SFT parameters:
LORA parameters:
Test set sampled from Samples from ReFinD dataset.
Overall Performance:
Precision: 0.77
Recall: 0.69
F1 Score: 0.71
Classification Report:
precision recall f1-score support
no_relation 0.00 0.00 0.00 0
title 0.00 0.00 0.00 0
operations_in 0.65 0.66 0.66 100
employee_of 0.00 0.00 0.00 0
agreement_with 0.58 0.88 0.70 100
formed_on 0.00 0.00 0.00 0
member_of 0.99 0.96 0.97 96
subsidiary_of 0.00 0.00 0.00 0
shares_of 0.00 0.00 0.00 0
revenue_of 0.60 0.27 0.38 95
loss_of 0.64 0.37 0.47 100
headquartered_in 0.99 0.73 0.84 100
acquired_on 0.00 0.00 0.00 0
founder_of 0.74 0.77 0.76 83
formed_in 0.96 0.91 0.93 100
accuracy 0.69 774
macro avg 0.41 0.37 0.38 774
weighted avg 0.77 0.69 0.71 774