Saravanankannan's picture
Create ReadMe
acd7b65 verified
Raw
History Blame Contribute Delete
3.48 kB
---
base_model: Qwen/Qwen2.5-32B-Instruct
library_name: peft
pipeline_tag: text-generation
license: apache-2.0
language:
- en
tags:
- base_model:adapter:Qwen/Qwen2.5-32B-Instruct
- lora
- qlora
- sft
- raft
- finance
- rag
- transformers
- trl
---
# Model Card for UnifiedQ-Finance-RAFT
**UnifiedQ-Finance-RAFT** is a specialized LoRA adapter for **Qwen 2.5 32B Instruct**, fine-tuned using the **RAFT (Retrieval-Augmented Fine-Tuning)** technique. It is designed to act as the reasoning engine for a quantitative finance RAG pipeline, specifically capable of distinguishing between relevant "oracle" documents and irrelevant "distractor" documents in complex options trading contexts.
## Model Details
### Model Description
This model was trained to solve the "distractor problem" in RAG systems. Standard models often get confused when a retrieval system pulls in irrelevant documents alongside the correct ones. By using the RAFT methodology, this model was explicitly trained on a dataset where it had to ignore noise and reason only from the relevant text chunks to answer complex financial queries.
- **Developed by:** Rednote (UnifiedQ Project)
- **Model type:** LoRA Adapter (QLoRA 4-bit) for Causal LM
- **Language(s):** English
- **License:** Apache 2.0 (Inherited from Qwen 2.5)
- **Finetuned from model:** [Qwen/Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct)
### Model Sources
- **Repository:** [More Information Needed - Link to your repo]
- **Technique Paper:** [RAFT: Adapting Language Model to Domain Specific RAG](https://arxiv.org/abs/2403.10131)
## Uses
### Direct Use
This model is intended to be used **with a RAG system** (Retrieval-Augmented Generation). It expects a prompt format that includes retrieved context documents (some relevant, some irrelevant) and a user question. It excels at:
- Options trading strategies evaluation.
- Risk management analysis.
- Filtering noise from retrieved financial documents.
### Out-of-Scope Use
- General chat without context (it is specialized for document-based reasoning).
- Financial advice (this is a research/development tool, not a financial advisor).
## How to Get Started with the Model
You can load this model using `peft` and `transformers`. Note that you must load the base model in 4-bit if running on consumer hardware.
```python
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# 1. Load Base Model (Qwen 2.5 32B)
base_model_id = "Qwen/Qwen2.5-32B-Instruct"
adapter_model_id = "Rednote/Qwen-2.5-32B-RAFT-UnifiedQ" # Replace with your actual HF path
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True,
attn_implementation="flash_attention_2" # Optional: remove if no Flash Attn
)
# 2. Load the RAFT Adapter
model = PeftModel.from_pretrained(base_model, adapter_model_id)
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
# 3. Inference Example
prompt = "Context: [Doc 1]... [Doc 2]... \n\n Question: How do I hedge delta risk?"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0]))