aashish1904
commited on
Commit
•
871fbb1
1
Parent(s):
035cd5d
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- finance
|
7 |
+
license: llama3
|
8 |
+
base_model: meta-llama/Meta-Llama-3-8B-Instruct
|
9 |
+
datasets:
|
10 |
+
- virattt/financial-qa-10K
|
11 |
+
language:
|
12 |
+
- en
|
13 |
+
pipeline_tag: text-generation
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
[![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
|
18 |
+
|
19 |
+
|
20 |
+
# QuantFactory/Llama-3-8B-Instruct-Finance-RAG-GGUF
|
21 |
+
This is quantized version of [curiousily/Llama-3-8B-Instruct-Finance-RAG](https://huggingface.co/curiousily/Llama-3-8B-Instruct-Finance-RAG) created using llama.cpp
|
22 |
+
|
23 |
+
# Original Model Card
|
24 |
+
|
25 |
+
|
26 |
+
# Llama 3 8B Instruct (Financial RAG)
|
27 |
+
|
28 |
+
This model is a fine-tuned version of the original [Llama 3 8B Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) model
|
29 |
+
on 4000 examples from the [virattt/financial-qa-10K](https://huggingface.co/datasets/virattt/financial-qa-10K) dataset.
|
30 |
+
|
31 |
+
The model is fine-tuned using a LoRA adapter for RAG use cases. It is optimized to answer a question based on a context:
|
32 |
+
|
33 |
+
```txt
|
34 |
+
Answer the question:
|
35 |
+
{question}
|
36 |
+
|
37 |
+
Using the information:
|
38 |
+
{context}
|
39 |
+
```
|
40 |
+
|
41 |
+
## Usage
|
42 |
+
|
43 |
+
Load the model:
|
44 |
+
|
45 |
+
```py
|
46 |
+
MODEL_NAME = "curiousily/Llama-3-8B-Instruct-Finance-RAG"
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=True)
|
48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
49 |
+
MODEL_NAME,
|
50 |
+
device_map="auto"
|
51 |
+
)
|
52 |
+
|
53 |
+
pipe = pipeline(
|
54 |
+
task="text-generation",
|
55 |
+
model=model,
|
56 |
+
tokenizer=tokenizer,
|
57 |
+
max_new_tokens=128,
|
58 |
+
return_full_text=False,
|
59 |
+
)
|
60 |
+
```
|
61 |
+
|
62 |
+
Format the prompt (uses the original Instruct prompt format):
|
63 |
+
|
64 |
+
````py
|
65 |
+
prompt = """
|
66 |
+
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
|
67 |
+
|
68 |
+
Use only the information to answer the question<|eot_id|><|start_header_id|>user<|end_header_id|>
|
69 |
+
|
70 |
+
How much did the company's net earnings amount to in fiscal 2022?
|
71 |
+
|
72 |
+
Information:
|
73 |
+
|
74 |
+
```
|
75 |
+
Net earnings were $17.1 billion in fiscal 2022.
|
76 |
+
```<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
77 |
+
"""
|
78 |
+
````
|
79 |
+
|
80 |
+
And make a prediction:
|
81 |
+
|
82 |
+
```py
|
83 |
+
print(outputs[0]["generated_text"])
|
84 |
+
```
|
85 |
+
|
86 |
+
```
|
87 |
+
$17.1 billion
|
88 |
+
```
|
89 |
+
|
90 |
+
Here's a helper function to build your prompts:
|
91 |
+
|
92 |
+
```py
|
93 |
+
def create_test_prompt(data_row):
|
94 |
+
prompt = dedent(f"""
|
95 |
+
{data_row["question"]}
|
96 |
+
|
97 |
+
Information:
|
98 |
+
|
99 |
+
```
|
100 |
+
{data_row["context"]}
|
101 |
+
```
|
102 |
+
""")
|
103 |
+
messages = [
|
104 |
+
{"role": "system", "content": "Use only the information to answer the question"},
|
105 |
+
{"role": "user", "content": prompt},
|
106 |
+
]
|
107 |
+
return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
108 |
+
```
|
109 |
+
|
110 |
+
Where `data_row` must be a dict:
|
111 |
+
|
112 |
+
```
|
113 |
+
data_row = {
|
114 |
+
"question": "...",
|
115 |
+
"context": "..."
|
116 |
+
}
|
117 |
+
```
|
118 |
+
|
119 |
+
## Sample Predictions
|
120 |
+
|
121 |
+
Here's a sample of the predictions from *trained* and *untrained* models
|
122 |
+
|
123 |
+
```txt
|
124 |
+
Example 1
|
125 |
+
|
126 |
+
answer: Delta Air Lines' agreements with its regional carriers typically last at least ten years with options for extensions. Delta controls operational aspects like scheduling and pricing.
|
127 |
+
|
128 |
+
trained: Delta Connection agreements typically last at least ten years with options for extensions.
|
129 |
+
|
130 |
+
untrained: According to the information, the terms of Delta Air Lines' agreements with its regional carriers through Delta Connection are:
|
131 |
+
|
132 |
+
1. The agreements typically last at least ten years.
|
133 |
+
2. There are options for extensions.
|
134 |
+
3. Delta controls major operational aspects like scheduling and pricing.
|
135 |
+
4. The regional carriers supply the services.
|
136 |
+
|
137 |
+
Example 2
|
138 |
+
|
139 |
+
answer: The company evaluates acquisition-related intangibles for impairment by comparing the asset's carrying amount to undiscounted future net cash flows expected from the asset. An impairment loss is recognized if the carrying amount exceeds the asset's recoverable amount.
|
140 |
+
|
141 |
+
trained: The company evaluates acquisition-related intangible and other long-lived assets for impairment whenever events or changes in circumstances indicate that the carrying amount may not be recoverable. This involves measuring the recoverability of the asset by comparing its carrying amount to the future undiscounted net cash flows expected to be generated by the asset group.
|
142 |
+
|
143 |
+
untrained: According to the information, the company uses the following criteria to determine whether an impairment loss should be recognized on acquisition-related intangible assets:
|
144 |
+
|
145 |
+
* Events or changes in circumstances that indicate the carrying amount of an asset may not be recoverable.
|
146 |
+
* A comparison of the carrying amount of an asset to future undiscounted net cash flows expected to be generated by the asset group.
|
147 |
+
|
148 |
+
In other words, the company evaluates whether the asset's carrying amount is recoverable by comparing it to the expected future cash flows, which involves assumptions about future prospects and computations of estimated future cash flows.
|
149 |
+
|
150 |
+
Example 3
|
151 |
+
|
152 |
+
answer: In the United States, the approval process for biosimilars is governed by the Public Health Service Act (PHSA) and the regulations implementing these statutes, specifically including provisions made under federal health care reform legislation enacted in March 2010.
|
153 |
+
|
154 |
+
trained: The Federal Food, Drug, and Cosmetic Act (the FFDCA) and the Public Health Service Act (PHSA)
|
155 |
+
|
156 |
+
untrained: The legal framework that governs the approval process for biosimilars in the United States is the Federal Food, Drug, and Cosmetic Act (FFDCA) and the Public Health Service Act (PHSA), as well as the regulations implementing these statutes.
|
157 |
+
|
158 |
+
Example 4
|
159 |
+
|
160 |
+
answer: Timothy S. Teter holds a B.S. degree in Mechanical Engineering from the University of California at Davis and a J.D. degree from Stanford Law School.
|
161 |
+
|
162 |
+
trained: B.S. in Mechanical Engineering from the University of California at Davis and a J.D. from Stanford Law School
|
163 |
+
|
164 |
+
untrained: According to the information, Timothy S. Teter holds:
|
165 |
+
|
166 |
+
1. A B.S. degree in Mechanical Engineering from the University of California at Davis.
|
167 |
+
2. A J.D. degree from Stanford Law School.
|
168 |
+
|
169 |
+
Example 5
|
170 |
+
|
171 |
+
answer: Beginning in fiscal year 2024, the company plans to exclude paused Connected Fitness subscriptions from its new 'Ending Paid Connected Fitness Subscriptions' metric and will treat a pause action as a churn event in its 'Average Net Monthly Paid Connected Fitness Subscription Churn' metric.
|
172 |
+
|
173 |
+
trained: Starting in fiscal year 2024, the company will no longer include paused Connected Fitness subscriptions in their Ending Paid Connected Fitness Subscriptions metric and will treat a pause action as a churn event in their Average Net Monthly Paid Connected Fitness Subscription Churn.
|
174 |
+
|
175 |
+
untrained: Starting in fiscal year 2024, the company will:
|
176 |
+
|
177 |
+
* No longer include paused Connected Fitness subscriptions in the Ending Paid Connected Fitness Subscriptions metric
|
178 |
+
* Treat a pause action as a churn event in the Average Net Monthly Paid Connected Fitness Subscription Churn
|
179 |
+
```
|
180 |
+
|
181 |
+
## License
|
182 |
+
|
183 |
+
Uses the original Llama 3 License.
|
184 |
+
A custom commercial license is available at: https://llama.meta.com/llama3/license
|