Instructions to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-32B-Instruct") model = PeftModel.from_pretrained(base_model, "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1") - Transformers
How to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1
- SGLang
How to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1 with Docker Model Runner:
docker model run hf.co/Saravanankannan/Qwen-2.5-32B-RAFT-Finance-v1
| --- | |
| 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])) |