Upload README.md
Browse files
README.md
CHANGED
@@ -9,15 +9,190 @@ tags:
|
|
9 |
- llama
|
10 |
- trl
|
11 |
- orpo
|
12 |
-
base_model:
|
13 |
---
|
|
|
|
|
14 |
|
15 |
# Uploaded model
|
16 |
|
17 |
- **Developed by:** baconnier
|
18 |
- **License:** apache-2.0
|
19 |
-
- **Finetuned from model :**
|
20 |
|
21 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
22 |
|
23 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
- llama
|
10 |
- trl
|
11 |
- orpo
|
12 |
+
base_model: cognitivecomputations/dolphin-2.9-llama3-8b
|
13 |
---
|
14 |
+
# This content is strictly for educational purposes and should not be construed as financial advice. Please exercise caution when applying any information provided.
|
15 |
+
|
16 |
|
17 |
# Uploaded model
|
18 |
|
19 |
- **Developed by:** baconnier
|
20 |
- **License:** apache-2.0
|
21 |
+
- **Finetuned from model :** cognitivecomputations/dolphin-2.9-llama3-8b
|
22 |
|
23 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
24 |
|
25 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
26 |
+
|
27 |
+
|
28 |
+
This model was trained ORPO , using ChatML prompt template format.
|
29 |
+
|
30 |
+
```
|
31 |
+
<|im_start|>user
|
32 |
+
Act as an exotic structurator and do not hesitate to merge standard and exotic products.
|
33 |
+
Currently, inflation is 5% and 1-year swaps are valued at 6%.
|
34 |
+
I expect inflation to reach 15% by the end of the year.
|
35 |
+
Can you create the 10 most complicated structured derivative products to handle this scenario?
|
36 |
+
Rank them by profitability, give me a score for profitability and another for risk from 0 to 10.
|
37 |
+
Add an explaination for each structured products in maximum of 3 sentences.
|
38 |
+
Think step by step and give me a concise, bulleted answer.<|im_end|>
|
39 |
+
<|im_start|>assistant
|
40 |
+
|
41 |
+
```
|
42 |
+
|
43 |
+
|
44 |
+
# Example with local TGI:
|
45 |
+
|
46 |
+
See the snippet below for usage with local inference:
|
47 |
+
```python
|
48 |
+
#Example: reuse your existing OpenAI setup
|
49 |
+
from openai import OpenAI
|
50 |
+
|
51 |
+
client = OpenAI(base_url="http://localhost:8080/v1", api_key="TGI")
|
52 |
+
|
53 |
+
completion = client.chat.completions.create(
|
54 |
+
model="baconnier/finance_dolphin_orpo_llama3_8B_r64_51K_GGUF-unsloth.Q4_K_M",
|
55 |
+
messages=[
|
56 |
+
{"role": "system", "content": "Act as a senior banker answering in 3 sentences in bullet points format."},
|
57 |
+
{"role": "user", "content": " What is CDS compare it to a swap "},
|
58 |
+
{"role": "assistant", "content": ""}
|
59 |
+
],
|
60 |
+
max_tokens=400,
|
61 |
+
temperature=0.7,
|
62 |
+
)
|
63 |
+
print(completion.choices[0].message.content)
|
64 |
+
```
|
65 |
+
Output:
|
66 |
+
```
|
67 |
+
CDS:
|
68 |
+
- Credit Default Swap (CDS) is a financial derivative contract between two parties (buyer and seller) for insurance against default or credit risk associated with a bond or loan
|
69 |
+
- Protection buyer pays a premium to protection seller in exchange for the right to receive payment if a credit event occurs
|
70 |
+
- Protection seller is usually a financial institution, while protection buyer can be an investor or a bank
|
71 |
+
Swap:
|
72 |
+
- Swap is an agreement between two parties to exchange cash flows, typically interest payments or principal at a future date
|
73 |
+
- Common types of swaps include interest rate swaps, currency swaps, and commodity swaps
|
74 |
+
CDS differs from swaps as it focuses on credit risk protection, while swaps involve cash flow exchange.
|
75 |
+
```
|
76 |
+
|
77 |
+
# Example with Transformers and pipeline:
|
78 |
+
|
79 |
+
See the snippet below for usage with Transformers:
|
80 |
+
|
81 |
+
```python
|
82 |
+
import transformers
|
83 |
+
import torch
|
84 |
+
|
85 |
+
model_id = "baconnier/finance_dolphin_orpo_llama3_8B_r64_51K"
|
86 |
+
|
87 |
+
pipeline = transformers.pipeline(
|
88 |
+
"text-generation",
|
89 |
+
model=model_id,
|
90 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
91 |
+
device="cuda",
|
92 |
+
)
|
93 |
+
|
94 |
+
messages = [
|
95 |
+
{"role": "user", "content": '''Act as an exotic structurator and do not hesitate to merge standard and exotic products.
|
96 |
+
Currently, inflation is 5% and 1-year swaps are valued at 6%.
|
97 |
+
I expect inflation to reach 15% by the end of the year.
|
98 |
+
Can you create the 10 most complicated structured derivative products to handle this scenario?
|
99 |
+
Rank them by profitability, give me a score for profitability and another for risk from 0 to 10.
|
100 |
+
Add an explaination for each structured products in maximum of 3 sentences.
|
101 |
+
Think step by step and give me a concise, bulleted answer.'''},
|
102 |
+
]
|
103 |
+
|
104 |
+
prompt = pipeline.tokenizer.apply_chat_template(
|
105 |
+
messages,
|
106 |
+
tokenize=False,
|
107 |
+
add_generation_prompt=True
|
108 |
+
)
|
109 |
+
|
110 |
+
prompt = pipeline.tokenizer.apply_chat_template(
|
111 |
+
messages,
|
112 |
+
tokenize=False,
|
113 |
+
add_generation_prompt=True
|
114 |
+
)
|
115 |
+
|
116 |
+
outputs = pipeline(
|
117 |
+
prompt,
|
118 |
+
max_new_tokens=256,
|
119 |
+
do_sample=True,
|
120 |
+
temperature=0.6,
|
121 |
+
top_p=0.9,
|
122 |
+
)
|
123 |
+
print(outputs[0]["generated_text"][len(prompt):])
|
124 |
+
```
|
125 |
+
|
126 |
+
Answer:
|
127 |
+
|
128 |
+
```
|
129 |
+
To handle the scenario of inflation reaching 15% by the end of the year, I can create the following 10 most complicated structured derivative products, ranked by profitability and risk:
|
130 |
+
|
131 |
+
1. Inflation-linked swap spread strategy (Profitability: 9, Risk: 7)
|
132 |
+
- Buy 1-year swaps and sell 15-year swaps to profit from the expected inflation increase.
|
133 |
+
- Risk is moderate due to interest rate and inflation rate changes.
|
134 |
+
|
135 |
+
2. Inflation-linked bond spread strategy (Profitability: 8, Risk: 6)
|
136 |
+
- Buy inflation-linked bonds and sell conventional bonds to profit from the inflation increase.
|
137 |
+
- Risk is lower than the swap spread strategy due to the fixed maturity of bonds.
|
138 |
+
|
139 |
+
3. Inflation-linked option strategy (Profitability: 7, Risk: 5)
|
140 |
+
- Buy call options on inflation-linked bonds to profit from the expected inflation increase.
|
141 |
+
- Risk is lower than the swap spread strategy due to the limited downside.
|
142 |
+
|
143 |
+
4. Inflation-linked credit spread strategy (Profitability: 6, Risk: 4)
|
144 |
+
- Buy high-yield inflation-linked bonds and sell investment-grade inflation-linked bonds to profit from the expected inflation increase.
|
145 |
+
- Risk is moderate due to credit risk and interest rate changes.
|
146 |
+
|
147 |
+
5. Inflation-linked swap straddle strategy (Profitability: 5, Risk: 3)
|
148 |
+
- Buy and sell 1-year and 15-year inflation swaps simultaneously to profit from the expected inflation increase.
|
149 |
+
- Risk is moderate due to interest rate and inflation rate changes.
|
150 |
+
|
151 |
+
6. Inflation-linked bond straddle strategy (Profitability: 4, Risk: 2)
|
152 |
+
- Buy and sell inflation-linked bonds with different maturities to profit from the expected inflation increase.
|
153 |
+
- Risk is lower than the swap straddle strategy due to the fixed maturity of bonds.
|
154 |
+
|
155 |
+
7. Inflation-linked option straddle strategy (Profitability: 3, Risk: 1)
|
156 |
+
- Buy and sell call options on inflation-linked bonds with different maturities to profit from the expected inflation increase.
|
157 |
+
- Risk is lower than the swap straddle strategy due to the limited downside.
|
158 |
+
|
159 |
+
8. Inflation-linked credit spread straddle strategy (Profitability: 2, Risk: 0)
|
160 |
+
- Buy and sell high-yield and investment-grade inflation-linked bonds with different maturities to profit from the expected inflation increase.
|
161 |
+
- Risk is low due to the fixed maturity of bonds and the limited downside.
|
162 |
+
|
163 |
+
9. Inflation-linked swap spread strangle strategy (Profitability: 1, Risk: -1)
|
164 |
+
- Buy and sell 1-year and 15-year inflation swaps with different strike prices to profit from the expected inflation increase.
|
165 |
+
- Risk is high due to interest rate and inflation rate changes.
|
166 |
+
|
167 |
+
10. Inflation-linked bond spread strangle strategy (Profitability: 0, Risk: -2)
|
168 |
+
- Buy and sell inflation-linked bonds with different strike prices to profit from the expected inflation increase.
|
169 |
+
- Risk is very high due to the limited downside and the potential for significant losses.
|
170 |
+
|
171 |
+
The most profitable strategies are the inflation-linked swap spread strategy and the inflation-linked bond spread strategy, with a profitability score of 9 and 8, respectively.
|
172 |
+
The least profitable strategy is the inflation-linked bond spread strangle strategy, with a profitability score of 0.
|
173 |
+
The most risky strategies are the inflation-linked swap spread strangle strategy and the inflation-linked bond spread strangle strategy, with a risk score of -1 and -2, respectively.
|
174 |
+
The least risky strategy is the inflation-linked credit spread straddle strategy, with a risk score of 0.
|
175 |
+
The 10 most complicated structured derivative products to handle the scenario of inflation reaching 15% by the end of the year are ranked by profitability and risk.
|
176 |
+
The most profitable strategies are the inflation-linked swap spread strategy and the inflation-linked bond spread strategy, with a profitability score of 9 and 8, respectively.
|
177 |
+
The least profitable strategy is the inflation-linked bond spread strangle strategy, with a profitability score of 0.
|
178 |
+
The most risky strategies are the inflation-linked swap spread strangle strategy and the inflation-linked bond spread strangle strategy, with a risk score of -1 and -2, respectively.
|
179 |
+
The least risky strategy is the inflation-linked credit spread straddle strategy, with a risk score of 0.
|
180 |
+
```
|
181 |
+
|
182 |
+
|
183 |
+
# Example with Transformers:
|
184 |
+
|
185 |
+
```python
|
186 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
187 |
+
|
188 |
+
tokenizer = AutoTokenizer.from_pretrained("baconnier/finance_dolphin_orpo_llama3_8B_r64_51K")
|
189 |
+
model = AutoModelForCausalLM.from_pretrained("baconnier/finance_dolphin_orpo_llama3_8B_r64_51K")
|
190 |
+
|
191 |
+
|
192 |
+
prompt = "What is CDS compare it to a swap"
|
193 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
194 |
+
|
195 |
+
# Generate
|
196 |
+
generate_ids = model.generate(inputs.input_ids, max_length=200)
|
197 |
+
tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
198 |
+
```
|