Browse Source

updates for external vlm call

master
Evgeniy Ierusalimov 1 day ago
parent
commit
6755c3fbdc
4 changed files with 23 additions and 116 deletions
  1. 0
    43
      3.md
  2. 0
    72
      3_1200_02.md
  3. 16
    0
      README.md
  4. 7
    1
      src/postprocess/qwen_client.py

+ 0
- 43
3.md View File

@@ -1,43 +0,0 @@
1
-
2
-## 2.1.Highlights of the IRB setup and evolution
3
-
4
-
5
-individual borrower's level.
6
-
7
-
8
-More than a decade later, the concept to consider a bunch of such individual borrowers was developed in Vasicek (1987). The starting point was to decompose the individual borrowers' pattern into specific (idiosyncratic) and common (systemic) components as in Eq. (1).
9
-
10
-$$
11
-A_{i}=Z\cdot r+u_{i}\cdot\sqrt{1-R}
12
-$$
13
-
14
-
15
-where - common factor; $u_{i}\sim N(0,1)$ -specific factor$ ,$
16
-
17
-
18
-$r=\mathrm{corr}(A_i,Z)$ $$ \rho \text{ (conventional mathematical correlation) as it originally appeared without a squared power in the works by Vasicek (1987); Gordy (2000)} \text{ (let us call it default correlation):} $$
19
-
20
-
21
-\(R=r^{2}\) - asset (value) correlation using BCBS notations (mathematically speaking, it is the square of the conventional mathematical correlation between \(A_{i}\) and \(Z\)).
22
-
23
-
24
-Due to the nice properties of the Gaussian distribution, Vasicek uses the Value-at-Risk (VaR) measure to slice the default rate (DR) distribution of the loan portfolio and arrives at the most feasible default rate realization given the chosen significance level of α in Eq. (2).
25
-
26
-$$
27
-V a R=N\left(\frac{N^{-1}(PD)+N^{-1}(1-\alpha)\cdot\sqrt{R}}{\sqrt{1-R}}\right).
28
-$$
29
-
30
-
31
-Important to note that Vasicek did not impose any restrictions on \( r \) over its feasible values. The only thing he notes is that in case \( r > 50\% \), the DR distribution becomes U-shaped (bimodal). Remembering the notations that \( R = r^2 \) or \( r = \sqrt{R} \), we should take away that Vasicek was speaking of DR distribution bimodality when the asset (value) correlation exceeds 25% (\( R > 25\% \)).
32
-
33
-
34
-006 BCBS amendment to the Vasicek model. The idea to internationally introduce model-based (IRB) credit risk regulation seems to have become popular after the success of such regulation introduction for the market risk in the Basel I amendment BCBS (1996). Thus, the very first draft of the future Basel II Accord incorporating IRB appeared on the edge of the new millennium, see Penikas (2020a), while it
35
-
36
-
37
-When designing IRB, the Basel Committee implemented five conceptual amendments, originally not previewed in the Vasicek model:
38
-
39
-
40
-1. BCBS chose the IRB significance level of $\alpha=0.1\%$ (inversely, confidence level of 99.9\%) which corresponds to the risk-measure breach (bank failure) once in one hundred years given the annual horizon for PD, see BCBS (2005a).
41
-
42
-
43
-2. BCBS added other credit risk parameters like loss given default (LGD), exposure at default (EAD), maturity (M) etc. For instance, VaR from Eq. (2) is multiplied by LGD and EAD.

+ 0
- 72
3_1200_02.md View File

@@ -1,72 +0,0 @@
1
-
2
-38
3
-
4
-$$
5
-1\mathrm{C Rec}_{\mathrm{it}}=\sum_{\mathrm{T}}^{\mathrm{t}}\mathrm{M Rec}_{\mathrm{it}} .
6
-$$
7
-
8
-
9
-где:
10
-
11
-
12
-i – индекс договора
13
-
14
-
15
-t — номер месяца в дефолте, на который прогнозируются возвраты для договора, в диапазоне между текущим сроком в дефолте и горизонтом взыскания:
16
-
17
-
18
-Т — рассчитанный горизонт взыскания
19
-
20
-
21
-$MBec_{i,t}$ — маржинальные возвраты, оцененные по модели, для договора $i$ в месяц $t$.
22
-
23
-
24
-7.1.10. На основе текущих полученных возвратов по дефолту на дату разработки модели и оцененной суммарной оставшейся доли возвратов к получению рассчитывается общий уровень потерь по дефолту за весь период взыскания с учетом экстраполяции (формула [18] ниже). В процессе моделирования минимальное экстраполированное значение уровня потерь ограничивается нулем.
25
-
26
-$$
27
-\mathrm{LGD\_extr_{i}}=\max(\mathrm{LGD\_act_{it}}-\mathrm{CRec_{it}},0) \mathrm{LGD\_extr_{i}}=\max(\mathrm{LGD\_act_{it}}-\mathrm{CRec_{it}},0) ______
28
-$$
29
-
30
-$$
31
-\mathrm{LGD\_act_{it}}=1-\frac{\sum_{t}\mathrm{DCF_{i,t}}}{\mathrm{EAD_{t}}}, ____
32
-$$
33
-
34
-
35
-где:
36
-
37
-
38
-$LGD\_extr_i$ — экстраполированное значение LGD для $i$-го договора в месяц нахождения в дефолте $t$;
39
-
40
-
41
-except — оцененная суммарная оставшаяся доля возвратов для $i$-го договора в месяц нахождения в дефолте $t$;
42
-
43
-
44
-$\mathrm{LGD\_act_{it}}$ - фактический уровень потерь для i -го договора в месяц нахождения вдефолте t;
45
-
46
-
47
-$\sum_t DCF_{i,t}$ — дисконтированная сумма возвратов, получаемых на t-ом периоде от созданной в дефолте;
48
-
49
-EAR — ожидаемая доходность из сети дефолта для договора i.
50
-
51
-
52
-11. Полученные значения уровней потерь для незавершенных д
53
-
54
-
55
-использованы в процессе моделирования. При учете таких дефолтов они рассматриваются как не выздоровевшие.
56
-
57
-7.2 Модель на основе дерева решений
58
-
59
-
60
-## 7.2.1. Данный подраздел применяется
61
-
62
-
63
-решений по ключевым характеристикам портфеля.
64
-
65
-
66
-[17]
67
-
68
-
69
-[18]
70
-
71
-
72
-[19]

+ 16
- 0
README.md View File

@@ -5,6 +5,22 @@
5 5
 
6 6
 ---
7 7
 
8
+## Предварительный шаг (обязательный)
9
+
10
+Перед запуском **любого** скрипта активируй виртуальное окружение:
11
+
12
+```bash
13
+source /home/ei/work/My/scan2html/.venv/bin/activate
14
+```
15
+
16
+После этого можно запускать скрипты, например:
17
+
18
+```bash
19
+python -m src.image_prepare -i scan.jpg -s 3:3 -o pages/
20
+```
21
+
22
+---
23
+
8 24
 ## Цель проекта
9 25
 
10 26
 Преобразование больших технических документов (JPEG/TIFF/PNG), полученных после печати и сканирования, в структурированный Markdown с формулами LaTeX, пригодный для:

+ 7
- 1
src/postprocess/qwen_client.py View File

@@ -48,11 +48,17 @@ def call_qwen_vlm(
48 48
         ],
49 49
     }]
50 50
 
51
+    headers = {
52
+        "x-api-key": _api_key(),
53
+        "anthropic-version": "2023-06-01",
54
+        "Content-Type": "application/json",
55
+        "x-opencode-session": "scan2html-ocr",
56
+    }
51 57
     for attempt in (1, 2, 3):
52 58
         try:
53 59
             r = requests.post(
54 60
                 API_URL,
55
-                headers={"x-api-key": _api_key(), "anthropic-version": "2023-06-01", "Content-Type": "application/json"},
61
+                headers=headers,
56 62
                 json={"model": model, "max_tokens": max_tokens, "messages": messages},
57 63
                 timeout=300,
58 64
             )

Loading…
Cancel
Save