Gaston-Llama-3-8B / README.md
baconnier's picture
Upload README.md
06d0582 verified
|
raw
history blame
9.27 kB
---
language:
- en
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- llama
- trl
- orpo
base_model: cognitivecomputations/dolphin-2.9-llama3-8b
---
# This content is strictly for educational purposes and should not be construed as financial advice. Please exercise caution when applying any information provided.
# Uploaded model
- **Developed by:** baconnier
- **License:** apache-2.0
- **Finetuned from model :** cognitivecomputations/dolphin-2.9-llama3-8b
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
This model was trained ORPO , using ChatML prompt template format.
```
<|im_start|>user
Act as an exotic structurator and do not hesitate to merge standard and exotic products.
Currently, inflation is 5% and 1-year swaps are valued at 6%.
I expect inflation to reach 15% by the end of the year.
Can you create the 10 most complicated structured derivative products to handle this scenario?
Rank them by profitability, give me a score for profitability and another for risk from 0 to 10.
Add an explaination for each structured products in maximum of 3 sentences.
Think step by step and give me a concise, bulleted answer.<|im_end|>
<|im_start|>assistant
```
# Example with local TGI:
See the snippet below for usage with local inference:
```python
#Example: reuse your existing OpenAI setup
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="TGI")
completion = client.chat.completions.create(
model="baconnier/finance_dolphin_orpo_llama3_8B_r64_51K_GGUF-unsloth.Q4_K_M",
messages=[
{"role": "system", "content": "Act as a senior banker answering in 3 sentences in bullet points format."},
{"role": "user", "content": " What is CDS compare it to a swap "},
{"role": "assistant", "content": ""}
],
max_tokens=400,
temperature=0.7,
)
print(completion.choices[0].message.content)
```
Output:
```
CDS:
- 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
- Protection buyer pays a premium to protection seller in exchange for the right to receive payment if a credit event occurs
- Protection seller is usually a financial institution, while protection buyer can be an investor or a bank
Swap:
- Swap is an agreement between two parties to exchange cash flows, typically interest payments or principal at a future date
- Common types of swaps include interest rate swaps, currency swaps, and commodity swaps
CDS differs from swaps as it focuses on credit risk protection, while swaps involve cash flow exchange.
```
# Example with Transformers and pipeline:
See the snippet below for usage with Transformers:
```python
import transformers
import torch
model_id = "baconnier/finance_dolphin_orpo_llama3_8B_r64_51K"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)
messages = [
{"role": "user", "content": '''Act as an exotic structurator and do not hesitate to merge standard and exotic products.
Currently, inflation is 5% and 1-year swaps are valued at 6%.
I expect inflation to reach 15% by the end of the year.
Can you create the 10 most complicated structured derivative products to handle this scenario?
Rank them by profitability, give me a score for profitability and another for risk from 0 to 10.
Add an explaination for each structured products in maximum of 3 sentences.
Think step by step and give me a concise, bulleted answer.'''},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
outputs = pipeline(
prompt,
max_new_tokens=256,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
print(outputs[0]["generated_text"][len(prompt):])
```
Answer:
```
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:
1. Inflation-linked swap spread strategy (Profitability: 9, Risk: 7)
- Buy 1-year swaps and sell 15-year swaps to profit from the expected inflation increase.
- Risk is moderate due to interest rate and inflation rate changes.
2. Inflation-linked bond spread strategy (Profitability: 8, Risk: 6)
- Buy inflation-linked bonds and sell conventional bonds to profit from the inflation increase.
- Risk is lower than the swap spread strategy due to the fixed maturity of bonds.
3. Inflation-linked option strategy (Profitability: 7, Risk: 5)
- Buy call options on inflation-linked bonds to profit from the expected inflation increase.
- Risk is lower than the swap spread strategy due to the limited downside.
4. Inflation-linked credit spread strategy (Profitability: 6, Risk: 4)
- Buy high-yield inflation-linked bonds and sell investment-grade inflation-linked bonds to profit from the expected inflation increase.
- Risk is moderate due to credit risk and interest rate changes.
5. Inflation-linked swap straddle strategy (Profitability: 5, Risk: 3)
- Buy and sell 1-year and 15-year inflation swaps simultaneously to profit from the expected inflation increase.
- Risk is moderate due to interest rate and inflation rate changes.
6. Inflation-linked bond straddle strategy (Profitability: 4, Risk: 2)
- Buy and sell inflation-linked bonds with different maturities to profit from the expected inflation increase.
- Risk is lower than the swap straddle strategy due to the fixed maturity of bonds.
7. Inflation-linked option straddle strategy (Profitability: 3, Risk: 1)
- Buy and sell call options on inflation-linked bonds with different maturities to profit from the expected inflation increase.
- Risk is lower than the swap straddle strategy due to the limited downside.
8. Inflation-linked credit spread straddle strategy (Profitability: 2, Risk: 0)
- Buy and sell high-yield and investment-grade inflation-linked bonds with different maturities to profit from the expected inflation increase.
- Risk is low due to the fixed maturity of bonds and the limited downside.
9. Inflation-linked swap spread strangle strategy (Profitability: 1, Risk: -1)
- Buy and sell 1-year and 15-year inflation swaps with different strike prices to profit from the expected inflation increase.
- Risk is high due to interest rate and inflation rate changes.
10. Inflation-linked bond spread strangle strategy (Profitability: 0, Risk: -2)
- Buy and sell inflation-linked bonds with different strike prices to profit from the expected inflation increase.
- Risk is very high due to the limited downside and the potential for significant losses.
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.
The least profitable strategy is the inflation-linked bond spread strangle strategy, with a profitability score of 0.
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.
The least risky strategy is the inflation-linked credit spread straddle strategy, with a risk score of 0.
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.
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.
The least profitable strategy is the inflation-linked bond spread strangle strategy, with a profitability score of 0.
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.
The least risky strategy is the inflation-linked credit spread straddle strategy, with a risk score of 0.
```
# Example with Transformers:
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("baconnier/finance_dolphin_orpo_llama3_8B_r64_51K")
model = AutoModelForCausalLM.from_pretrained("baconnier/finance_dolphin_orpo_llama3_8B_r64_51K")
prompt = "What is CDS compare it to a swap"
inputs = tokenizer(prompt, return_tensors="pt")
# Generate
generate_ids = model.generate(inputs.input_ids, max_length=200)
tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
```