Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: other
|
| 4 |
+
tags:
|
| 5 |
+
- finance
|
| 6 |
+
- risk-relation
|
| 7 |
+
- retrieval
|
| 8 |
+
- encoder
|
| 9 |
+
- feature-extraction
|
| 10 |
+
- stock-prediction
|
| 11 |
+
pipeline_tag: feature-extraction
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Financial Risk Identification through Dual-view Adaptation — Encoder
|
| 15 |
+
|
| 16 |
+
This repository hosts the pretrained encoder from the work **“Financial Risk Identification through Dual-view Adaptation.”**
|
| 17 |
+
The model is designed to uncover **inter-firm risk relations** from financial text, supporting downstream tasks such as **retrieval**, **relation mining**, and **stock-signal experiments** where relation strength acts as a feature.
|
| 18 |
+
|
| 19 |
+
> **Files**
|
| 20 |
+
> - `pytorch_model.safetensors` — model weights
|
| 21 |
+
> - `config.json` — model configuration
|
| 22 |
+
> - *(optional but recommended)* `README.md` (this file)
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## ✨ What’s special (Dual-view Adaptation)
|
| 27 |
+
|
| 28 |
+
The model aligns two complementary “views” of firm relations and adapts them during training:
|
| 29 |
+
|
| 30 |
+
- **Lexical view (`lex`)** — focuses on token/phrase-level and domain terms common in 10-K and financial news.
|
| 31 |
+
- **Temporal view (`time`)** — encourages stability/consistency of relations across reporting periods and evolving events.
|
| 32 |
+
|
| 33 |
+
A **two-view combination (“Best”)** integrates both signals and yields stronger retrieval quality and more stable risk-relation estimates. Ablations (`lex`, `time`) are also supported for analysis.
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## 🔧 Intended Use
|
| 38 |
+
|
| 39 |
+
- **Feature extraction / sentence embeddings** for paragraphs, sections, or documents in financial filings.
|
| 40 |
+
- **Retrieval & ranking**: compute similarities between queries (e.g., “supply chain risk for X”) and candidate passages.
|
| 41 |
+
- **Risk-relation estimation**: aggregate cross-document similarities to produce pairwise firm relation scores used in downstream analytics.
|
| 42 |
+
|
| 43 |
+
> ⚠️ Not a generative LLM. Use it as an **encoder** (feature extractor).
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## 🚀 Quickstart (Transformers)
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
import torch
|
| 51 |
+
from transformers import AutoTokenizer, AutoModel
|
| 52 |
+
|
| 53 |
+
MODEL_ID = "william0816/Dual_View_Financial_Encoder" # replace with your repo id
|
| 54 |
+
|
| 55 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=True)
|
| 56 |
+
model = AutoModel.from_pretrained(MODEL_ID)
|
| 57 |
+
|
| 58 |
+
def mean_pool(last_hidden_state, attention_mask):
|
| 59 |
+
# Mean-pool w.r.t. the attention mask
|
| 60 |
+
mask = attention_mask.unsqueeze(-1).type_as(last_hidden_state)
|
| 61 |
+
summed = (last_hidden_state * mask).sum(dim=1)
|
| 62 |
+
counts = torch.clamp(mask.sum(dim=1), min=1e-9)
|
| 63 |
+
return summed / counts
|
| 64 |
+
|
| 65 |
+
texts = [
|
| 66 |
+
"The company faces supplier concentration risk due to a single-source vendor.",
|
| 67 |
+
"Management reported foreign exchange exposure impacting Q4 margins."
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
enc = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
|
| 71 |
+
with torch.no_grad():
|
| 72 |
+
outputs = model(**enc)
|
| 73 |
+
embeddings = mean_pool(outputs.last_hidden_state, enc["attention_mask"])
|
| 74 |
+
|
| 75 |
+
# Cosine similarity for retrieval
|
| 76 |
+
emb_norm = torch.nn.functional.normalize(embeddings, p=2, dim=1)
|
| 77 |
+
similarity = emb_norm @ emb_norm.T
|
| 78 |
+
print(similarity)
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
## 🖇️ Citation
|
| 82 |
+
If you use this model or the dual-view methodology, please cite:
|
| 83 |
+
```bibtex
|
| 84 |
+
@misc{financial_risk_dualview_2025,
|
| 85 |
+
title = {Financial Risk Identification through Dual-view Adaptation},
|
| 86 |
+
author = {Chiu, Wei-Ning and collaborators},
|
| 87 |
+
year = {2025},
|
| 88 |
+
note = {Preprint/Project},
|
| 89 |
+
howpublished = {\url{https://huggingface.co/william0816/Dual_View_Financial_Encoder}}
|
| 90 |
+
}
|