You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-40Lines changed: 82 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
<divalign="center">
2
-
2
+
3
3
<imgsrc="assets/logo.png">
4
-
4
+
5
5
</div>
6
6
7
7
[](https://colab.research.google.com/github/oidlabs-com/Lexoid/blob/main/examples/example_notebook_colab.ipynb)
@@ -35,6 +35,21 @@ OPENAI_API_KEY=""
35
35
GOOGLE_API_KEY=""
36
36
```
37
37
38
+
For local inference with Ollama, no API key is required. Install Ollama, pull the target model, and keep the local server running:
Copy file name to clipboardExpand all lines: docs/api.rst
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,12 @@ parse
33
33
* ``api_cost_mapping`` (Union[dict, str]): Dictionary containing API cost details or the string path to a JSON file containing
34
34
the cost details. Sample file available at ``tests/api_cost_mapping.json``
35
35
* ``router_priority`` (str): What the routing strategy should prioritize. Options are ``"speed"`` and ``"accuracy"``. The router directs a file to either ``"STATIC_PARSE"`` or ``"LLM_PARSE"`` based on its type and the selected priority. If priority is "accuracy", it prefers LLM_PARSE unless the PDF has no images but contains embedded/hidden hyperlinks, in which case it uses ``STATIC_PARSE`` (because LLMs currently fail to parse hidden hyperlinks). If priority is "speed", it uses ``STATIC_PARSE`` for documents without images and ``LLM_PARSE`` for documents with images.
36
-
* ``api_provider`` (str): The API provider to use for LLM parsing. Options are ``gemini``, ``openai``, ``claude``, ``huggingface``, ``together``, ``openrouter``, and ``fireworks``. This parameter is only relevant when using LLM parsing.
36
+
* ``api_provider`` (str): The API provider to use for LLM parsing. Options are ``gemini``, ``openai``, ``claude``, ``huggingface``, ``together``, ``openrouter``, ``fireworks``, and ``ollama``. This parameter is only relevant when using LLM parsing. For Ollama, use an explicit provider selection such as ``api_provider="ollama"`` with a local model like ``gemma4:latest``.
37
37
* ``return_bboxes`` (bool): Whether to return bounding box information for each text segment. Default is ``False``.
38
38
39
39
Return value format:
40
40
A dictionary containing a subset or all of the following keys:
41
-
41
+
42
42
* ``raw``: Full markdown content as string
43
43
* ``segments``: List of dictionaries with metadata and content of each segment. For PDFs, a segment denotes a page. For webpages, a segment denotes a section (a heading and its content).
44
44
* ``title``: Title of the document
@@ -58,7 +58,7 @@ parse_with_schema
58
58
59
59
:param path: Path to the PDF file.
60
60
:param schema: JSON schema to which the parsed output should conform.
61
-
:param api: LLM API provider to use (``"gemini"``, ``"openai"``, ``"claude"``, ``"huggingface"``, ``"together"``, ``"openrouter"``, or ``"fireworks"``).
61
+
:param api: LLM API provider to use (``"gemini"``, ``"openai"``, ``"claude"``, ``"huggingface"``, ``"together"``, ``"openrouter"``, ``"fireworks"``, or ``"ollama"``).
62
62
:param model: LLM model name.
63
63
:param kwargs: Additional keyword arguments passed to the LLM (e.g., ``temperature``, ``max_tokens``).
64
64
:return: A list where each element represents a page, which in turn contains a list of dictionaries conforming to the provided schema.
@@ -105,6 +105,15 @@ LLM-Based Parsing
105
105
# Parse using Gemini 1.5 Pro
106
106
result = parse("document.pdf", parser_type="LLM_PARSE", model="gemini-1.5-pro")
107
107
108
+
# Parse using a local Ollama model
109
+
result = parse(
110
+
"document.pdf",
111
+
parser_type="LLM_PARSE",
112
+
api_provider="ollama",
113
+
model="gemma4:latest",
114
+
max_processes=1,
115
+
)
116
+
108
117
109
118
Static Parsing
110
119
^^^^^^^^^^^^^^
@@ -137,7 +146,7 @@ Parse with Schema
137
146
]
138
147
139
148
pdf_path ="inputs/test_1.pdf"
140
-
result = parse_with_schema(path=pdf_path, schema=sample_schema, model="gpt-4o")
149
+
result = parse_with_schema(path=pdf_path, schema=sample_schema, model="gpt-4o")
0 commit comments