DeepSeek OCR 2: automatski dobijamo LaTeX iz složenog dokumenta

2026-04-02

← Nazad na blog

Cilj ovog testa je bio praktičan: proveriti da li se složen PDF dokument može pretvoriti u upotrebljiv LaTeX fajl knjige uz DeepSeek OCR 2 lokalno, bez spoljnih API-ja.

Izvorni dokument o pomorskim čarterima imao je gustu strukturu: mnogo naslova i podnaslova, veliki broj linkova i fusnota. Ključno pitanje nije bilo samo prepoznavanje teksta, već da li je moguće sačuvati strukturu i vratiti fusnote u formatu pogodnom za dalju redakturu i prevod.

Primer stranice izvornog dokumenta o pomorskim čarterima

Ako vam treba lokalni OCR za složene dokumente (knjige, pravilnike, ugovorne materijale) i želite rezultat spreman za biznis, a ne „sirov OCR“, zadatak možete poslati kroz brif.

Pošalji brif

Šta smo proveravali

  1. Da li se stranice složene knjige mogu stabilno prepoznavati u lokalnom okruženju.
  2. Da li OCR izlazi mogu da se spoje tako da se sačuvaju i struktura i fusnote.
  3. Da li izlaz može biti jedan LaTeX fajl spreman za sledeću fazu obrade.

Rezultat

Test je bio uspešan: dobijen je jedinstven završni LaTeX fajl knjige.

Drugim rečima, hipoteza je potvrđena: za ovu klasu dokumenata može da se dobije upotrebljiv LaTeX kroz lokalni OCR pipeline i postobradu.

Sledeća faza ovog istog slučaja je automatizovani prevod dobijenog LaTeX-a na ruski uz Qwen 2.5 32B, sa quality-gate korakom i hibridnim doterivanjem: poseban post o prevodu.

Mašina i resursi

  • Mašina: MacBook Pro M1, 32 GB RAM.
  • Pokretanje: u Docker-u, CPU režim.
  • Inference režim: cpu, float32, attn_impl=eager.

Performanse po terminal logu

Ovako je izgledao rad u terminalu: u priloženom delu loga za stranice 0178 i 0179, obrada jedne stranice trajala je oko 18-21 minut, a učitavanje težina modela pre obrade oko 39-44 sekunde.

Terminal log pokretanja DeepSeek OCR 2: CPU režim, vreme obrade po stranici i vreme učitavanja modela

Tehnički detalji

Dokument je obrađivan stranicu po stranicu. Za svaku stranicu korišćena su dva OCR prolaza:

  • strukturni prolaz (daje uredniju hijerarhiju teksta),
    <image>
    <|grounding|>
    Convert the document to markdown.
    
  • puni OCR prolaz (bolje izvlači kompletan tekst, uključujući fusnote),
    <image>
    Free OCR.

Zatim su izlazi spajani: struktura je uzimana iz prvog prolaza, a fusnote i izgubljeni fragmenti iz drugog. Nakon toga je formiran jedinstven LaTeX fajl i poseban spisak mesta za ručnu proveru.

Model i tačna revizija: deepseek-ai/DeepSeek-OCR-2 @ aaa02f3811945a91062062994c5c4a3f4c0af2b0.

Primeri OCR izlaza

Ispod su dva realna fragmenta sa jedne prepoznate stranice: strukturni Markdown izlaz i puni Free OCR izlaz.

Primer Markdown prepoznavanja (otvori)

Komentar: u ovom režimu se bolje čuva struktura dokumenta (naslovi i sekcije), ali pojedini elementi poput fusnota mogu da se izgube ili pojednostave.

<|ref|>text<|/ref|><|det|>[[102, 79, 887, 145]]<|/det|>
not be underplayed. In Papas Olio JSC v. Grains & Fourrages, \( ^{12} \)  Toulson L.J. said that, in most cases, the recap fulfils a dual function of confirming evidently the making of the oral agreement and also superseding the oral agreement by providing a document to which the parties can then look as the expression of their bargain. As Lord Blackburn said in Rossiter v. Miller \( ^{13} \) :
<|ref|>text<|/ref|><|det|>[[138, 156, 887, 315]]<|/det|>
It is a necessary part of the plaintiff’s case to show that the two parties had come to a final and complete agreement, for, if not, there was no contract. So long as they are only in negotiation either party may retract; and though the parties may have agreed on all the cardinal points of the intended contract, yet, if some particulars essential to the agreement still remain to be settled afterwards, there is no contract. The parties, in such a case, are still only in negotiation. But the mere fact that the parties have expressly stipulated that there shall afterwards be a formal agreement prepared, embodying the terms, which shall be signed by the parties does not, by itself, show that they continue merely in negotiation. It is a matter to be taken into account in construing the evidence and determining whether the parties have really come to a final agreement or not. But as soon as the fact is established of the final mutual assent of the parties so that those who draw up the formal agreement have not the power to vary the terms already settled, I think the contract is completed.
<|ref|>text<|/ref|><|det|>[[103, 327, 886, 360]]<|/det|>
1.4 Those particulars that are “essential to the agreement” and that must therefore be settled before a binding contract exists, may fall into two categories, namely:
<|ref|>text<|/ref|><|det|>[[103, 361, 885, 393]]<|/det|>
(i) terms that, if not settled, render the entire agreement unworkable, or void for uncertainty, with the result that the court is unable to enforce it, whatever the parties may have intended;
<|ref|>text<|/ref|><|det|>[[103, 394, 885, 427]]<|/det|>
(ii) terms, the agreement upon which is regarded by the parties themselves as an essential prerequisite of the making of a binding contract. \( ^{14} \)
<|ref|>sub_title<|/ref|><|det|>[[103, 450, 810, 483]]<|/det|>
## Matters which must be agreed if the contract is not to be unworkable or void for uncertainty
<|ref|>text<|/ref|><|det|>[[102, 491, 886, 557]]<|/det|>
1.5 As Bingham J. said in Pagnan v. Feed Products, \( ^{15} \)  “the parties are to be regarded as masters of their contractual fate”, and it is primarily up to them whether agreement upon any particular matter is to be a prerequisite of a binding contract. However, the issue is not subjective, as noted by Lord Clarke \( ^{16} \) :
<|ref|>text<|/ref|><|det|>[[137, 568, 887, 686]]<|/det|>
The general principles are not in doubt. Whether there is a binding contract between the parties and if so, upon what terms depends on what they have agreed. It depends not upon their subjective state of mind, but upon a consideration of what was communicated between them by words or conduct and whether that leads objectively to a conclusion that they intended to create legal relations and had agreed upon all the terms which they regard or the law requires as essential for the formation of legally binding relations. Even if certain terms of economic or other significance to the parties have not been finalised, an objective appraisal of their words and conduct may lead to the conclusion that they did not intend agreement of such terms to be a pre-condition to a concluded and legally binding agreement.
<|ref|>text<|/ref|><|det|>[[104, 697, 844, 714]]<|/det|>
As Andrew Smith J. expressed it in Bear Stearns Bank plc v. Forum Global Equity Ltd \( ^{17} \) :
<|ref|>text<|/ref|><|det|>[[103, 729, 885, 755]]<|/det|>
12 [2010] 2 Lloyd’s Rep. 152, at para. 28 and see also TTMI Sarl v. Statoil ASA (The Sibolelle) [2011] 2 Lloyd’s Rep. 220, at para. 31.
<|ref|>text<|/ref|><|det|>[[130, 755, 366, 768]]<|/det|>
13 (1878) 3 App. Cas. 1124, 1151.
<|ref|>text<|/ref|><|det|>[[103, 768, 885, 793]]<|/det|>
14 See Pagnan v. Feed Products [1987] 2 Lloyd’s Rep. 601, 619; Spectra International v. Tiscali [2002] All E.R.(D) 209.
<|ref|>text<|/ref|><|det|>[[103, 794, 886, 845]]<|/det|>
15 Ibid. at p. 611. This is a description which the courts have repeatedly adopted: see, e.g., RTS Flexible Systems Ltd v. Molenski Alois Muller GmbH & Co. [2010] 1 W.L.R. 753 and Air Studios (Lyndhurst) Ltd v. Lombard North Central (T/A Air Entertainment Group) [2013] 1 Lloyd’s Rep. 63, where Males J. set out the principles concerning the present issue with great clarity at paras 5–12.
<|ref|>text<|/ref|><|det|>[[103, 845, 885, 871]]<|/det|>
16 RTS Flexible Systems Ltd v. Molenski Alois Muller GmbH & Co. [2011] 1 W.L.R. 753; and see Barbudev v. Eurocom Cable Management Bulgaria EOOD [2012] 2 All E.R. (Comm) 963.
<|ref|>text<|/ref|><|det|>[[103, 871, 885, 897]]<|/det|>
17 [2007] EWHC 1576 (Comm), at para. 171; and the same judge in Macro Volatility Master Fund v. Rouvray [2009] 1 Lloyd’s Rep. 475, at para. 223.
Primer Free OCR prepoznavanja (otvori)

Komentar: u ovom režimu se bolje izvlači kompletan tekst, uključujući fusnote, ali je struktura (hijerarhija naslova/sekcija) obično manje uredna.

not be underplayed. In Papas Olio JSC v. Grains & Fourrages,\(^{12}\) Toulson L.J. said that, in most cases, the recap fulfils a dual function of confirming evidentially the making of the oral agreement and also superseding the oral agreement by providing a document to which the parties can then look as the expression of their bargain. As Lord Blackburn said in Rossiter v. Miller\(^{13}\):
It is a necessary part of the plaintiff’s case to show that the two parties had come to a final and complete agreement, for, if not, there was no contract. So long as they are only in negotiation either party may retract; and though the parties may have agreed on all the cardinal points of the intended contract, yet, if some particulars essential to the agreement still remain to be settled afterwards, there is no contract. The parties, in such a case, are still only in negotiation. But the mere fact that the parties have expressly stipulated that there shall afterwards be a formal agreement prepared, embodying the terms, which shall be signed by the parties does not, by itself, show that they continue merely in negotiation. It is a matter to be taken into account in construing the evidence and determining whether the parties have really come to a final agreement or not. But as soon as the fact is established of the final mutual assent of the parties so that those who draw up the formal agreement have not the power to vary the terms already settled, I think the contract is completed.
1.4 Those particulars that are “essential to the agreement” and that must therefore be settled before a binding contract exists, may fall into two categories, namely:
(i) terms that, if not settled, render the entire agreement unworkable, or void for uncertainty, with the result that the court is unable to enforce it, whatever the parties may have intended;
(ii) terms, the agreement upon which is regarded by the parties themselves as an essential prerequisite of the making of a binding contract.\(^{14}\)
**Matters which must be agreed if the contract is not to be unworkable or void for uncertainty**
1.5 As Bingham J. said in *Pagnan v. Feed Products*,\(^{15}\) “the parties are to be regarded as masters of their contractual fate”, and it is primarily up to them whether agreement upon any particular matter is to be a prerequisite of a binding contract. However, the issue is not subjective, as noted by Lord Clarke\(^{16}\):
The general principles are not in doubt. Whether there is a binding contract between the parties and if so, upon what terms depends on what they have agreed. It depends not upon their subjective state of mind, but upon a consideration of what was communicated between them by words or conduct and whether that leads objectively to a conclusion that they intended to create legal relations and had agreed upon all the terms which they regard or the law requires as essential for the formation of legally binding relations. Even if certain terms of economic or other significance to the parties have not been finalised, an objective appraisal of their words and conduct may lead to the conclusion that they did not intend agreement of such terms to be a pre-condition to a concluded and legally binding agreement.
As Andrew Smith J. expressed it in *Bear Stearns Bank plc v. Forum Global Equity Ltd\(^{17}\)*:
12 [2010] 2 Lloyd’s Rep. 152, at para. 28 and see also *TTMI Sarl v. Statoil ASA (The Sibolelle)* [2011] 2 Lloyd’s Rep. 220, at para. 31.
13 (1878) 3 App. Cas. 1124, 1151.
14 See *Pagnan v. Feed Products* [1987] 2 Lloyd’s Rep. 601, 619; *Spectra International v. Tiscali* [2002] All E.R.(D) 209.
15 *Ibid.* at p. 611. This is a description which the courts have repeatedly adopted: see, e.g., *RTS Flexible Systems Ltd v. Molenski Alois Muller GmbH & Co.* [2010] 1 W.L.R. 753 and *Air Studios (Lyndhurst) Ltd v. Lombard North Central (T/A Air Entertainment Group)* [2013] 1 Lloyd’s Rep. 63, where Males J. set out the principles concerning the present issue with great clarity at paras 5–12.
16 *RTS Flexible Systems Ltd v. Molenski Alois Muller GmbH & Co.* [2009] 1 W.L.R. 753; and see *Barbudev v. Eurocom Cable Management Bulgaria EOOD* [2012] 2 All E.R. (Comm) 963.
17 [2007] EWHC 1576 (Comm), at para. 171; and the same judge in *Macro Volatility Master Fund v. Rouvray* [2009] 1 Lloyd’s Rep. 475, at para. 223.
  • Pokušaji poboljšanja rezultata kroz eksperimentisanje sa promptovima nisu dali primetan dobitak.
  • U praksi su stabilno radila samo dva režima: „convert to markdown“ i „Free OCR“.
  • Najbolji praktični rezultat nije dao jedan „idealni“ prolaz, već spajanje ova dva izlaza.
  • Dobijeni LaTeX je dobar kao osnova za sledeću fazu: ručnu lekturu i prevod na ruski.