Files changed (1) hide show
  1. README.md +71 -0
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - finance
5
+ - retrieval
6
+ - candlestick
7
+ - k-line
8
+ - vicreg
9
+ - contrastive-learning
10
+ - RAG
11
+ ---
12
+
13
+ # FinAlogy — VICReg Morphology-Aware Encoder
14
+
15
+ This repository contains the pretrained visual encoder and demo data for **FinAlogy**, a visual analogy retrieval system for financial K-line analysis.
16
+
17
+ - 💻 Code: [https://github.com/nice-zzy/FinAlogy](https://github.com/nice-zzy/FinAlogy)
18
+ - ▶️ Demo Video: [https://youtu.be/oq1_hxYAE9M](https://youtu.be/oq1_hxYAE9M)
19
+
20
+ ---
21
+
22
+ ## Files
23
+
24
+ | File | Description |
25
+ |---|---|
26
+ | `checkpoint_best.pth` | Pretrained VICReg encoder checkpoint (CLIP-ViT-B/32 backbone, 675 MB) |
27
+ | `finalogy_demo_instances.zip` | Demo K-line instances for quick inference testing |
28
+
29
+ ---
30
+
31
+ ## Model Description
32
+
33
+ The encoder is a **CLIP-ViT-B/32** backbone fine-tuned with **VICReg** self-supervised learning on DOW30 historical K-line data (2010–2021). It maps candlestick chart images into a 512-dimensional morphology-aware embedding space, capturing shape-level properties (body size, shadow structure, local trend direction) while remaining invariant to absolute price scales.
34
+
35
+ **Training details:**
36
+ - Backbone: CLIP-ViT-B/32
37
+ - Loss: VICReg (λ = µ = 5)
38
+ - Data: DOW30 components, 2010–2020 (train), 2021 (test)
39
+ - Window size: W = 5 trading days
40
+ - Silver-pair threshold: τ = 0.98
41
+
42
+ **Evaluation (test set, 2,075 unique anchors):**
43
+
44
+ | Method | 52D Alignment |
45
+ |---|---|
46
+ | Barlow Twins | 0.785 |
47
+ | SimSiam | 0.814 |
48
+ | **VICReg (ours)** | **0.910** |
49
+
50
+ > 52D Alignment measures cosine similarity between retrieved results and the query in the 52-dimensional morphological feature space — higher is better. VICReg achieves the best morphological alignment among all compared methods.
51
+
52
+ ---
53
+
54
+ ## Usage
55
+
56
+ ```python
57
+ import torch
58
+ from huggingface_hub import hf_hub_download
59
+
60
+ # Download checkpoint
61
+ ckpt_path = hf_hub_download(
62
+ repo_id="ZiyaZhao/FinAlogy",
63
+ filename="checkpoint_best.pth"
64
+ )
65
+
66
+ # Load encoder
67
+ checkpoint = torch.load(ckpt_path, map_location="cpu")
68
+ # See https://github.com/nice-zzy/FinAlogy for full inference pipeline
69
+ ```
70
+
71
+ For the full retrieval and report generation pipeline, see the [GitHub repository](https://github.com/nice-zzy/FinAlogy).